whenever i use mysql_connect() It gives Fatal errror of using unidentfied function
i'm using mysql version 4 on windows 7, what to do? it looks like php never heard of
that function, wonder if someone does have a straight forward solution?

Have you got the correct modules enabled in your php.ini file?

Member Avatar for diafol

Is there any reason why you're using mysql 4? The beta version of MySQL 5.0 was available in 2005 and 5.1 was official in 2008. Although that shouldn't stop you using mysql itself, makes me wonder what antiquated stuff you're trying to run.

hericles;
thank u for ur immediate reply, here are the settings in my php.ini- some were already uncommented and i did some, pls be patient to check what are the culpritsa:

disable_functions =
disable_classes =
doc_root =
user_dir =
extension_dir = "/ext"
enable_dl = Off
**Extencions:
extension=msql.dll
extension=php_mysql.dll
extension=php_mysqli.dll
pdo_mysql.cache_size = 2000
pdo_mysql.default_socket=
SMTP = localhost
smtp_port = 25
sql.safe_mode = Off
**mysql
mysql.allow_local_infile = On
mysql.allow_persistent = On
mysql.cache_size = 2000
mysql.max_persistent = -1
mysql.max_links = -1
mysql.default_port ="3036";
mysql.default_socket =
mysql.default_host ="c:\inetpub\wwwroot"
mysql.default_user ="samyyoussef"
mysql.default_password ="sifudeen1309"
mysql.connect_timeout = 60
mysql.trace_mode = Off
**[MySQLi]
mysqli.max_persistent = -1
mysqli.allow_persistent = On
mysqli.max_links = -1
mysqli.cache_size = 2000
mysqli.default_port = 3306
mysqli.default_socket =
mysqli.default_host =”localhost”
mysqli.default_user =”samyyoussef”
mysqli.default_pw =”sifudeen1309”
mysqli.reconnect = Off
**[mysqlnd]
mysqlnd.collect_statistics = On
mysqlnd.collect_memory_statistics = On
**[MSSQL]
mssql.allow_persistent = On
mssql.max_persistent = -1
mssql.max_links = -1
mssql.min_error_severity = 10
mssql.min_message_severity = 10
mssql.compatibility_mode = Off
mssql.secure_connection = Off

OK, create a script with

<?php
  phpinfo();
?>

and run it. Look for MySql in the resulting tables. If it isn't there then something is missing. Maybe the MySql driver?

diafol;
thank u for immediate reply;
Actually i was trying to get any sql to use, to be honest i don't know the mysterious meanings like Beta version, in facat i'm instructing the material. so i first downloaded mysql 4 to go with my win 7 -32bits, then later i downloaded php 5 to connect to mysql, but the php.info file does mention mysqlnd, as u know it is hard to uninstall php 5 from the computer, so if u have any suitable combination to work with, pls tell me,

Member Avatar for diafol

mysqlnd is the native driver. You may be using mysqld driver. The native driver is often not enabled in cheap hosting sites too.

I can't see any need to uninstall php. I f you have missing drivers - copy them (ensure you use the same version and vc version). In addition you can enable a driver or extension in your php.ini file by taking off the ';' semi-colon at the start of the line.

With regard to versions, you should always go for the last stable version of everything if possible. PHP 5.5, MySQL 5.6 are available. Pay attention to the threaded/non-threaded, bit and VC versions of PHP.

diafol;
thank again;
the php version from the info file is: PHP Version 5.6.0RC1;
any recommendations for the proper mysql version needed to work just on my clocalhost, mysql is doing the job, i just need to get result via php script
but every time i get the message:
Fatal error: Call to undefined function mysqli_connect() in C:\inetpub\wwwroot\dbtest.php on line 5
aloso i have read that The MySQL native driver for PHP is an additional, alternative way to connect from PHP 5.3 or newer to the MySQL Server 4.1 or newer.

diafol;
one more thing i discovered that i'm usng mysql server version 5.1 not 4 as i gussed as i selected 4 to download in the first place;

got tired and depressed, i downloaded a new mysql version, it works fine at the mysql command line, but every time for a month now i try PHP Version 5.6.0RC1 function mysql_connect() i get this terrible error message:Fatal error: Call to undefined function mysql_connect(). I'm using mysql ver 5.6
Arn't there any genious to help??????

Member Avatar for iamthwee

Are you using wamp xamp? My advice would be to uninstall and do a fresh install.

That will clean all the paths including the PHP paths.

iamthwee;

thank u for ur quick response;
i'm just using php and mysql, i'm trying to handle mysql databse through php through a simple script like this:

<?php
$dbhost = 'localhost:3036';
$dbuser = 'root';
$dbpass = 'rootpassword';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn )
{
  die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
$sql = 'CREATE Database test_db';
$retval = mysql_query( $sql, $conn );
if(! $retval )
{
  die('Could not create database: ' . mysql_error());
}
echo "Database test_db created successfully\n";
mysql_close($conn);
?>
I don't know where is the problem. i did all php.ini settings required
Member Avatar for diafol

The usual port for a mysql server is 3306 not 3036.

Do you need to specify the port in your connection details?

i did changed the port number like u said, also i used mysqli_connect(), mysqlnd_connect() and everytime i recieve the same message:
Fatal error: Call to undefined function mysql_connect() in C:\inetpub\wwwroot\dbtest.php on line 5

Member Avatar for diafol

Take off the port completely. However, I don't think that would stop you using mysql functions - or more correctly - give you this particular error.

Looking at your path, are you using IIS as your webserver instead of Apache?

I would suggest using the webserver that you are likely to encounter on your host / remote server. This will probably be Apache. ALthough there are differences between Linux/Apache/PHP and Windows/Apache/PHP, they pale into insignificance compared to the differences between Linux/Apache/PHP and Windows/IIS/PHP.

There are other webservers of course. Again I'm not sure that this would be an issue with MySQL. Can you run MySQL from the command prompt?

yes i can use mysql command line; however i will be trying Apache instead of the localhost;
thank u;

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.