PHP Fatal Error: Call to Undefined Function mysql_connect()
Posted: Thu Aug 22, 2013 7:02 pm
Hi Guys
I am running windows xp and php 5.35 and mysql databases 8.0 and apache 2.27
When I run a simple php script (test.php) to connect to a mysql database and retrieve data, I get this:
Fatal error: Call to undefined function mysql_connect()
I know it is because Php cannot locate the mysql library so as adviced on the net I set the following as follows:
1. update php.ini file in my C:/windows folder as follows:
;extension_dir = "./" ===> extension_dir = "C:/php/ext"
2. set the environment system : path= C:/php
The php_mssql.dll is located in C:/php/ext and the libmysql.dll driver is in C:/php so both should be found by the php engine. However, When I try to connect to mysl using php
(from test.php) I still get the same error call:
Fatal error: Call to undefined function mysql_connect()
Meanwhile I am able to update my database using command line calls to mysql. So clearly the fault lies with my Php set up.
The test.php script is as follows:
----------------------------------
<?php
$con=mysql_connect("localhost","root","01959719");
// Check connection
if (mysql_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
// Create database
$sql="CREATE DATABASE customer";
if (mysql_query($con,$sql))
{
echo "Database aqurium created successfully";
}
else
{
echo "Error creating database: " . mysql_error($con);
}
?>
---------------------------------------
PLEASE ADVICE
Thanks
I am running windows xp and php 5.35 and mysql databases 8.0 and apache 2.27
When I run a simple php script (test.php) to connect to a mysql database and retrieve data, I get this:
Fatal error: Call to undefined function mysql_connect()
I know it is because Php cannot locate the mysql library so as adviced on the net I set the following as follows:
1. update php.ini file in my C:/windows folder as follows:
;extension_dir = "./" ===> extension_dir = "C:/php/ext"
2. set the environment system : path= C:/php
The php_mssql.dll is located in C:/php/ext and the libmysql.dll driver is in C:/php so both should be found by the php engine. However, When I try to connect to mysl using php
(from test.php) I still get the same error call:
Fatal error: Call to undefined function mysql_connect()
Meanwhile I am able to update my database using command line calls to mysql. So clearly the fault lies with my Php set up.
The test.php script is as follows:
----------------------------------
<?php
$con=mysql_connect("localhost","root","01959719");
// Check connection
if (mysql_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
// Create database
$sql="CREATE DATABASE customer";
if (mysql_query($con,$sql))
{
echo "Database aqurium created successfully";
}
else
{
echo "Error creating database: " . mysql_error($con);
}
?>
---------------------------------------
PLEASE ADVICE
Thanks