Php runs normally on the computer, but it does not work properly on the linux Terminal.

Source: Internet
Author: User
Php runs normally on the computer on the linux Terminal but it does not solve the headache among my php file content: always prompt fatalerror; calltoamemberfunctionquery () onanon-objectonline16 $ DB-& gt; connection-& gt; query (& quot; createtabletest (idi php runs normally on the computer on the linux terminal, but it does not solve the problem.
My php file content:

Always prompts fatal error; call to a member function query () on a non-object online 16

$ DB-> connection-> query ("create table test (id integer primary key, name varchar (50), grade varchar (50), score varchar (50 ))"); this line of error always prompts me to paste it here

It is completely normal for me to run on the computer. I can insert data. when I run the data on a linux Terminal, I keep prompting that the error is going crazy. Is it a problem with terminal settings?



Header ("content-Type: text/html; charset = Utf-8 ");

// Obtain the data submitted on the uiceshi.html page
$ Fname = $ _ POST ['fname']; // name
$ Fgrade = $ _ POST ['fgrade ']; // grade
$ Fscore = $ _ POST ['fscore']; // score

// $ SQL = 'Insert into test values ();';

// Create a database instance

$ DB = new SQLite ('Blog. db'); // the database file name is arbitrary.

// Create a table named test
$ DB-> connection-> query ("create table test (id integer primary key, name varchar (50), grade varchar (50), score varchar (50 ))"); this line of error is prompted

// Execute the insert statement
// $ Result = $ DB-> query ("insert into test (name, grade, score) values ('". $ fname. "','". $ fgrade. "','". $ fscore. "')");
$ Result = $ DB-> connection-> query ("insert into test (name, grade, score) values ('". $ fname. "','". $ fgrade. "','". $ fscore. "')");

// The returned results are mainly used for debugging.
Print_r ($ result );


// SQLite class
Class SQLite
{
Function _ construct ($ file)
{
Try
{
$ This-> connection = new PDO ('sqlite: '. $ file );
}
Catch (PDOException $ e)
{
Try
{
$ This-> connection = new PDO ('sqlite2: '. $ file );
}
Catch (PDOException $ e)
{
Exit ('error! ');
}
}
}

Function _ destruct ()
{
$ This-> connection = null;
}

Function query ($ SQL) // Runs SQL directly, which can be used to update or delete data.
{
Return $ this-> connection-> query ($ SQL );
}

Function getlist ($ SQL) // retrieves the record list
{
$ Recordlist = array ();
Foreach ($ this-> query ($ SQL) as $ rstmp)
{
$ Recordlist [] = $ rstmp;
}
Return $ recordlist;
}

Function Execute ($ SQL)
{
Return $ this-> query ($ SQL)-> fetch ();
}

Function RecordArray ($ SQL)
{
Return $ this-> query ($ SQL)-> fetchAll ();
}

Function RecordCount ($ SQL)
{
Return count ($ this-> RecordArray ($ SQL ));
}

Function RecordLastID ()
{
Return $ this-> connection-> lastInsertId ();
}
}
?>

------ Solution --------------------
SQLITE in LINUX is not installed.
------ Solution --------------------
Does the directory where SQLITE data files are stored have the write permission?

Discussion

But it can be read out. if you put data. db in the linux underground, the terminal can read but cannot insert data.

------ Solution --------------------
Grant 7777 permissions
------ Solution --------------------

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.