Page 1 of 1

PHP Fatal Error: Call to Undefined Function mysql_connect()

Posted: Thu Aug 22, 2013 7:02 pm
by xbear1982
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

Re: PHP Fatal Error: Call to Undefined Function mysql_connec

Posted: Thu Aug 22, 2013 7:06 pm
by requinix
xbear1982 wrote:php 5.35 and mysql databases 8.0 and apache 2.27
None of those versions exist.

Did you also uncomment the line

Code: Select all

extension = php_mysql.dll
and restart your web server?

Re: PHP Fatal Error: Call to Undefined Function mysql_connec

Posted: Thu Aug 22, 2013 7:14 pm
by xbear1982
sorry I make the mistake it is mysql 6.0 and php 5.3.5 and appache webserver 2.2

I remove the # character in extention in php.ini. but the problem still exist


Please help


Thanks in advance

Re: PHP Fatal Error: Call to Undefined Function mysql_connec

Posted: Thu Aug 22, 2013 9:20 pm
by requinix
There's no MySQL 6.0 either.

The extension= line will have a semicolon, not a hash sign. And did you restart?