Page 1 of 1

mysql_connect() error

Posted: Sun Aug 28, 2005 11:44 pm
by xs2manish
Hello everyone

This is my first post on this forum.
i m a newbie in php infact in programming.
i have the mysql_connect() error on the page.

thankx in advance

Posted: Sun Aug 28, 2005 11:47 pm
by John Cartwright
1) Welcome to the forums :)
2) Post your code
3) Post your error

Posted: Mon Aug 29, 2005 1:30 am
by s.dot
You should use the mysql_error() to help you figure out what is wrong.

Or use the example given on the PHP manual for mysql_connect, which is:

Code: Select all

<?php
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
   die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);
?>
Or if you're getting an 'undefined function mysql_connect' then you need to enable mysql support

thanks for such quick response

Posted: Mon Aug 29, 2005 1:42 am
by xs2manish
thanks for such quick response. m sure will find a solution here

have used the mysql_error() func.

error : call to an undefined function mysql_connect()

i m using php in iis

Posted: Mon Aug 29, 2005 1:59 am
by s.dot
I had this error when I used PHP 5. I downgraded to PHP 4.3 and everything worked out fine.

However, I wouldn't recommend doing that. You have to enable mysql support or something or other, in which case I couldn't tell you what to do. Although someone in here should be along shortly with a more precise answer. :-D

Posted: Mon Aug 29, 2005 2:02 am
by feyd
uncomment the php_mysql.dll line in your php.ini, make sure the file(s) are in your extensions folder and/or path.

Posted: Mon Aug 29, 2005 2:03 am
by John Cartwright
viewtopic.php?t=23651&highlight=call+un ... sqlconnect

or search "call to an undefined function mysql_connect()" with search for all terms...
this has been discussed and solved many, many times.

Posted: Mon Aug 29, 2005 3:33 am
by m3mn0n
Indeed.

Basically, you're on PHP 5 and it doesn't include MySQL out of the box like PHP 4 did. You'll need to install it and configure your setup to enable it.

Check out the link Jcart posted for more info. And don't be a stranger to the manual! :) http://www.php.net/mysql

now get the error the cgi timed out

Posted: Mon Aug 29, 2005 8:15 am
by xs2manish
I am trying to install php on iis on my web server. what all i tried is here :

1. did uncomment php_mysql.dll
2. i installed php5 through an auto installer so didnt get the ext folder which has the dll files so i downloaded the windows zip package and copied the ext folder to c:\php
3. set the path of extension_dir="c:\php\ext\"
4. did set the environment variable to php. mean i added the following to the entry of path in system variables ;c:\php . this was done i guess so that the php and mysql can communicate with each other


before trying anything of the above i mean apart from using the php auto installer i was able to run the php pages atleast.

now even the page which has just the phpinfo stmt is showing a cgi timed out errror

i do not know what am i lagging here.

thanks in advance for the help offered

Posted: Mon Aug 29, 2005 8:21 am
by feyd
any start-up errors in php's logs, or the server's? (If you are using php in CGI mode, they may only happen when you try to load a php file)

Alternately, is it a requirement to run IIS? Most of us use Apache, I believe.

Posted: Mon Aug 29, 2005 8:54 am
by xs2manish
i know that mostly php is used on apache but here it is a compulsion for me to use iis

m not sure how to check for the errors that have asked for

but in iis settings i have even tried to make the php as isapi by doing the following:

1) in iis -> isapi filters added the php in isapi filters.
filter name : php
executable : C:\php\php5isapi.dll

2) in home directory -> configurations -> application mappings

executable :C:\php5\php5isapi.dll
extension : .php

Posted: Mon Aug 29, 2005 9:08 am
by xs2manish
before this in iis -> home directory -> configuration -> application mappings

the executable was : php-cgi.exe