You are here:

PHP5/issue with sqli object in php code

Advertisement


Question
Hi,

I had recently asked you about an issue with using msqli objects in my php code. As far as errors generated is concerned, no such error message is generated. It's just a blank page, instead, that is being produced off the code. Also, I checked the configuration details of my PHP, and mysqli is enabled in it. Here's a screenshot of the same: http://i.imgur.com/uftEjun.png?1

Kindly let me know what's to be done next.

Thanks.
PS I have also added the extension folder's directory in the php.ini file and uncommented the extension definitions for mysql and myslqi (in php.ini).

Answer
Hello Ashish,
I would recommend following the example in the mysqli quick start guide at http://us2.php.net/manual/en/mysqli.quickstart.statements.php:
$mysqli = new mysqli("example.com", "user", "password", "database");
if ($mysqli->connect_errno) {
   echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}

if (!$mysqli->query("DROP TABLE IF EXISTS test") ||
   !$mysqli->query("CREATE TABLE test(id INT)") ||
   !$mysqli->query("INSERT INTO test(id) VALUES (1)")) {
   echo "Table creation failed: (" . $mysqli->errno . ") " . $mysqli->error;
}

Try this (substituting your connection info) and you should see an indication of what is happening.
Regards,
Robert

PHP5

All Answers


Answers by Expert:


Ask Experts

Volunteer


Robert Davis

Expertise

My focus in PHP has been calculations, reporting, database manipulation (MySQL), automated scripting, screen scraping, and tracking systems. A summary of my business is posted at www.businesscatalyst.info.

Experience

I've been programming in many languages for over 15 years, but the last several years I've focused on php for websites and perl for data processing. I've posted several tricks I've learned at www.wilycode.com.

Education/Credentials
I have a bachelors degree and a masters degree, both in electrical engineering from Arizona State University.

©2016 About.com. All rights reserved.