PHP Fatal Error: Call to Undefined Function mysql_connect()

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
xbear1982
Forum Newbie
Posts: 9
Joined: Sun Aug 18, 2013 10:50 pm

PHP Fatal Error: Call to Undefined Function mysql_connect()

Post 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
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: PHP Fatal Error: Call to Undefined Function mysql_connec

Post 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?
xbear1982
Forum Newbie
Posts: 9
Joined: Sun Aug 18, 2013 10:50 pm

Re: PHP Fatal Error: Call to Undefined Function mysql_connec

Post 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
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: PHP Fatal Error: Call to Undefined Function mysql_connec

Post by requinix »

There's no MySQL 6.0 either.

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