mysql - php fatal call to member function prepare() on non object -


I'm exploring everywhere to answer why my PDO prepared () function is giving me this error: / P>

PHP Fatal Error: Call a member function () in line in /var/www/database.class.php Create non-object

I will talk about this Seeing the post but none of them help to clarify this error. I started here: use it with a poster Some changes to come

This is my database. Class.php:

  & lt ;? Php class database {Private $ Host = "Localhost"; Private $ user = "nicholas"; Private $ pass = "12345"; Private $ dbname = "sstest"; Private $ dBH; Private $ error; Public $ stmt; Public function __ composition () {$ dsn = 'mysql: host =' $ this- & gt; Host '; Dbname = '$ this- & gt; Dbname; $ Option = array (PDO :: ATTR_PERSISTENT = & gt; true, PDO :: ATTRRAMODE = & gt; PDO :: ERRMODE_EXCEPTION); {$ This-> Dbh = Try new PDO ($ dsn, $ this- & gt; user, $ this- & gt; pass, $ option); } Hold (PDOException $ E) {$ this-> Error = $ e-> GetMessage (); }} Public Function Query ($ query) {$ this- & gt; Stmt = $ this- & gt; Dbh- & gt; Ready ($ query); // this line 26} public function bind ($ param, $ value, $ type = zero) {if (is_null ($ type)) {switch (true) {case is_int ($ value): $ type = PDO :: PARAM_INT; break; Case is_bool ($ value): $ type = PDO :: PARAM_NULL; break; Default: $ type = PDO :: PARAM_STR; break; }} $ This-> Stmt-> Byte value ($ param, $ value, $ type); } Execute Public Function () {Return $ the-> gt; Stmt-> carry about (); } Public function result () {$ this-> carry about (); Return- $$ - this-> Stmt-> Fetch All (PDO :: FETCH_ASSOC); } Public Celebration Single () {$ this- & gt; Executed (); Return-this-> gt; Stmt-> Obtain (PDO _ :: FETCH_ASSOC); } Public function rowCount () {return $ this-> Stmt-> Punctiquity (); } Public event lastInsertId () {return $ this- & gt; Dbh- & gt; LastInsertId (); } Start public celebration () {return $ this- & gt; Dbh- & gt; Starting restriction (); } Public Function endTransaction () {Return $ this- & gt; Dbh- & gt; Commit (); } Public Function cancelTransaction () {Return $ this-> Dbh- & gt; Rollback (); }}? & Gt;  

And here is a php file using my database:

   

I know that Java code is sending postal data, but I understand that the ready () function is saying that $ sql is a non-object. Any help is highly appreciated, has been working on it for 2 days and can not get ready (previous) statement

I think your problem is here:

  try $$ - & gt; Dbh = new PDO ($ DSN, $ this-> user, $ this-> pass, $ option); } Hold (PDOException $ E) {$ this-> Error = $ e-> GetMessage (); }  

Add this line to catch after that line, which you have the line:

  var_dump ($ this-> error); Exit;);  

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

lua - HowTo create a fuel bar -