Page 1 of 1

mysql functions are not working

Posted: Wed Jun 22, 2005 5:09 am
by bugthefixer
i have recently installed php and mysql on my system
the problem is all other functions are working properly but only
mysql related functions are not working like
mysql_connect
mysql_select_db etc.

do i have to configure something in php.ini or something else

Posted: Wed Jun 22, 2005 5:10 am
by shiznatix
how do you know they arn't working? show what your code is, maybe you made a mistake in your code

Posted: Wed Jun 22, 2005 5:21 am
by bugthefixer
The code is :

Code: Select all

<?
$HTTP_HOST=&quote;localhost&quote;;
//$DOCROOT=&quote;localhost&quote;;

$conn=mysql_connect(&quote;localhost&quote;,&quote;root&quote;,&quote;123&quote;) or die(&quote;Not Connected&quote;);

mysql_select_db(&quote;test&quote;,$conn) or die(&quote;Could not connectd to database&quote;);
if($conn)
{
echo &quote;Database is successfully connected&quote;;
}
else
{
echo &quote;Database is not connected.&quote;;
}
?>
error is:

Call to undefined function mysql_connect()

Posted: Wed Jun 22, 2005 5:40 am
by phpScott
check your php.ini file and make sure to remove the ; before the mysql.dll in the extensions section if you are using windows then restart your server.

If it is linux then one of the great linux guru's around here will have to instruct you.

do a phpinfo() and I think that mysql is not loaded.

Posted: Wed Jun 22, 2005 6:00 am
by bugthefixer
well thanks guru but the only thing i found in php.ini is

extension = php_mysql.dll

not just mysql.dll

and now i got this error:

unable to load dynamic library php_mysql.dll

Posted: Wed Jun 22, 2005 6:14 am
by phpScott
sorry for the wrong extension name but you found it.

next you will have to check the your the path to your extension_dir

mine for example is
extension_dir = "c:/development/php/extensions/"

in the php.ini file.

make sure that the php_mysql.dll is in the directory.

what version of php are you running?

Posted: Wed Jun 22, 2005 6:19 am
by bugthefixer
thanx guru but i dont have extensions folder at all in my php folder...i hav searched through the net and i found out that sometimes such dlls are mising in php version 5...so if u hav any idea about where kan i find this dll..bcause i hav searched php.net but i cudnt find...or if u hav any other solution in ur mind ..i wud really apreciate

Posted: Wed Jun 22, 2005 6:25 am
by phpScott
you used the installer didn't you?

go to http://www.php.net/downloads.php and download the windows zip package as believe there it comes with the right extensions dir called ext. copy and past it into your php folder the set the extension_dir to that folder in your php.ini folder.

Posted: Wed Jun 22, 2005 6:36 am
by facets
If i may but in here.. I use easyphp from easyphp.org and have found it too be a great little application.
It installs apache/php/mysql/phpmyadmin for you. Which leaves you time to code instead of debugging systems setups.

PS. I use this on my local machine for developing not as a server app.

cheers, will.

Posted: Wed Jun 22, 2005 6:53 am
by bugthefixer
sorry to bother u again guru
now i did eaxactly the same thing i have copied the est folder to c:/php folder and extension_dir = ':\php\bin\'
but still i hav got the same error but this time it shows the path that it cannot find c:\php\bin\php_mysql.dll

but i dont understand now why it doesnt pick the dll library

Posted: Wed Jun 22, 2005 7:06 am
by phpScott
no worries.

change extension_dir to

extension_dir = 'c:/php/ext/'

and hopefully it will work.

for some reason if have always found it easier to use exact directory paths when working with windows and the WAMP set up.

Mysql

Posted: Wed Jun 22, 2005 7:09 am
by asmie
Hie,

You have to set ur extensions directory in the php.ini file.
Change it as follows :

extension_dir = "C:/php/ext/"

You have to store all ur extension dlls in this folder.
You should then enable the mysql extension.

extension=php_mysql.dll


A s m i e

Posted: Wed Jun 22, 2005 7:49 am
by bugthefixer
i m sorry i might be making u guys crazy but i did that now everything is perfect..i hav also coppied php_mysql.dll in winnt folder and system folder and i hav also set the environment variable path ...but still its not working...

Posted: Wed Jun 22, 2005 8:35 am
by asmie
hey

you have to store the php_mysql.dll in the extensions directory. in Winnt php has an "ext" folder. There you have to store your dll file.


A s m i e

Posted: Wed Jun 22, 2005 8:44 am
by phpScott
create a file and call it phpinfo.php

copy and paste the code below into it

Code: Select all

<?php

phpinfo();

?>
save the file some where you server can access it and run the file.

do you see mysql in the list?

what is the error message you are getting now?