mysql functions are not working

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bugthefixer
Forum Contributor
Posts: 118
Joined: Mon Mar 22, 2004 2:35 am

mysql functions are not working

Post 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
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

how do you know they arn't working? show what your code is, maybe you made a mistake in your code
bugthefixer
Forum Contributor
Posts: 118
Joined: Mon Mar 22, 2004 2:35 am

Post 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()
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

Post 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.
bugthefixer
Forum Contributor
Posts: 118
Joined: Mon Mar 22, 2004 2:35 am

Post 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
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

Post 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?
bugthefixer
Forum Contributor
Posts: 118
Joined: Mon Mar 22, 2004 2:35 am

Post 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
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

Post 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.
facets
Forum Contributor
Posts: 273
Joined: Wed Apr 13, 2005 1:53 am
Location: Detroit

Post 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.
bugthefixer
Forum Contributor
Posts: 118
Joined: Mon Mar 22, 2004 2:35 am

Post 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
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

Post 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.
asmie
Forum Newbie
Posts: 11
Joined: Mon Jun 20, 2005 8:45 am

Mysql

Post 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
bugthefixer
Forum Contributor
Posts: 118
Joined: Mon Mar 22, 2004 2:35 am

Post 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...
asmie
Forum Newbie
Posts: 11
Joined: Mon Jun 20, 2005 8:45 am

Post 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
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

Post 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?
Post Reply