MySQL Forums
Forum List  »  PHP

Fatal error: Call to undefined function mysqli_connect()
Posted by: Jarryd Crawford
Date: September 23, 2007 10:39PM

I'm really new to SQL / PHP / Apache, which is the combo I'm using at the moment to test databases out on my pc locally. I'm using a guide to test if I can access MySQL by using PHP.

I've tried to connect with the following, but I get the error

"Fatal error: Call to undefined function mysqli_real_connect() in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\mysql_up.php on line 13"

I have the "php5apache2_2.dll" in my root C:\php directory to be accessed;

I have configured the Apache "httpd.conf" file and added the line "LoadModule php5_module "C:/PHP/php5apache2_2.dll"";

I was told to "magic_quotes_gpc = Off" within the php.ini in my C:\windows directory, and also to add "extension=php_mysqli.dll" to it in the extension section;

I have "libmysql.dll" in my root C:\php directory.

I am accessing the php file through localhost/mysql_up.php


The coding is:

<?php
/* Program: mysql_up.php
* Desc: Connects to MySQL Server and
* outputs settings.
*/
echo "<html>
<head><title>Test MySQL</title></head>
<body>";
$host="localhost";
$user="";
$password="";

$cxn = mysqli_real_connect($host,$user,$password);
$sql="SHOW STATUS";
$result = mysqli_query($cxn,$sql);
if($result == false)
{
echo "<h4>Error: ".mysqli_error($cxn)."</h4>";
}
else
{
/* Table that displays the results */
echo "<table border='1'>
<tr><th>Variable_name</th>
<th>Value</th></tr>";
for($i = 0; $i < mysqli_num_rows($result); $i++)
{
echo "<tr>";
$row_array = mysqli_fetch_row($result);
for($j = 0;$j < mysqli_num_fields($result);$j++)
{
echo "<td>".$row_array[$j]."</td>\n";
}
}
echo "</table>";
}
?>
</body></html>

If anyone can enlighten me on what I'm doing wrong, that would be great :)

Thanks in advance



Edited 1 time(s). Last edit at 09/23/2007 10:40PM by Jarryd Crawford.

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.