Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

php-mysql test script errors

Status
Not open for further replies.

akelabanda

Programmer
Dec 19, 2001
61
IN
Hello Guys

I'm a newbie with php and mysql. I found a couple of tutorials on the web and got a small test script which confirms that php connects to mysql server correctly.

Here's the test script -
-------------------
<?php
mysql_connect("localhost","root","tester") or die(mysql_error());
echo "Connected to MySQL<br />";
?>
-------------------

I ran this script on command line using php -l option. There are no syntax errors. But when I run with -f option it errors as below -

-------------------
C:\Apache2.2\htdocs\test>php -f mysql_test.php
PHP Fatal error: Call to undefined function mysql_connect() in C:\Apache2.2\htdocs\test\mysql_test.
php on line 2
-------------------

I'm wondering if additinal configuration's required on php for mysql.

Please help. I'm able to run php and mysql individually all by themselves.

Thanks
Rajeev

UK's best mobile deals online
 
The -l option only checks for syntax, but doesn't actually run the file.

You should check your PHP.ini and make sure the mysql extension is uncommented and that the dll exists inside the extensions folder.





----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Hi Vacunita

The following is set in the php.ini

extension_dir = "./" and both php_mysqli.dll and libmysql.dll are present in the C:\php5 directory.

Also entered in php.ini

extension=php_mysqli.dll
extension=libmysql.dll

Still complains about the same.

Thanks
Rajeev

UK's best mobile deals online
 
Now resolved. I did the following.

Downloaded mysql extension (PHP 5.2.0) from

Unzipped the dlls into c:\php5 (my php install directory) as by default extension_dir = "./" in php.ini

Uncommented extension=php_mysql.dll in php.ini

Restarted Apache, MYSQL

It works now.

UK's best mobile deals online
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top