11.07.2015 Views

PHP MySQL - Stilson.net

PHP MySQL - Stilson.net

PHP MySQL - Stilson.net

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 30 • USING <strong>PHP</strong> WITH MYSQLwww.it-ebooks.infoThis returns:Mysql error number generated: 1045Retrieving Error MessagesThe error() method returns the most recently generated error message, or it returns an empty string ifno error occurred. Its prototype follows:class mysqli {string error}The message language is dependent upon the <strong>MySQL</strong> database server because the target language ispassed in as a flag at server startup. A sampling of the English-language messages follows:Sort abortedToo many connectionsCouldn't uncompress communication packetAn example follows:// Connect to the database server$mysqli = new mysqli('localhost', 'catalog_user', 'secret', 'corporate');if ($mysqli->errno) {printf("Unable to connect to the database: %s",$mysqli->error);exit();}For example, if the incorrect password is provided, you’ll see the following message:Unable to connect to the database:Access denied for user 'catalog_user'@'localhost' (using password: YES)592

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!