mysql_connect() error

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
xs2manish
Forum Commoner
Posts: 26
Joined: Mon Aug 22, 2005 10:46 pm

mysql_connect() error

Post 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
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

1) Welcome to the forums :)
2) Post your code
3) Post your error
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post 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
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
xs2manish
Forum Commoner
Posts: 26
Joined: Mon Aug 22, 2005 10:46 pm

thanks for such quick response

Post 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
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post 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
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post 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.
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post 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
xs2manish
Forum Commoner
Posts: 26
Joined: Mon Aug 22, 2005 10:46 pm

now get the error the cgi timed out

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
xs2manish
Forum Commoner
Posts: 26
Joined: Mon Aug 22, 2005 10:46 pm

Post 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
xs2manish
Forum Commoner
Posts: 26
Joined: Mon Aug 22, 2005 10:46 pm

Post by xs2manish »

before this in iis -> home directory -> configuration -> application mappings

the executable was : php-cgi.exe
Post Reply