Hi, I've been trying to set up a webserver for a while now, but with no luck. Here is the problem:-
After I installed PHP,Apache,MySQL into a folder named 'server' on my local machine and followed the relevant steps to set them up; I used the following script to check if mysqli queries were working:
<?php
@ $db = new mysqli('localhost','genericUser','genericPassword','example_db');
if(mysqli_connect_errno())
{
echo 'Error: Could not connect at this time';
exit;
}
if($db)
{
$query = 'select * from news_posts';
$result = $db->query($query);
$num_results = $result->num_rows;
echo 'There are '.$num_results.' rows';
}
$db->close();
?>
Unfortunately it returned the following error messages :-
Warning: mysqli::query() [mysqli.query]: Couldn't fetch mysqli in C:\server\Apache2.2\htdocs\serverResp.php on line 11
Notice: Trying to get property of non-object in C:\server\Apache2.2\htdocs\serverResp.php on line 12
There are rows
Warning: mysqli::close() [mysqli.close]: Couldn't fetch mysqli in C:\server\Apache2.2\htdocs\serverResp.php on line 15
Ive tried everything to resolve these errors, but as yet, nothing has worked. Assuming its something to do with the extension, I've even checked the phpinfo();
, but the output tells me that the mysqli extension is installed.
If anyone can help me with this, it would be greatly appreciated.
I'm running Windows Vista 32bit Ultimate with apache2.2.11,PHP 5.3.0 and MySQL 5.1.36
(Sorry if this turns out to be the wrong section for this. I'm assuming its a php problem.)