[SOLVED] PHP Novice: Help!: Database connection from script
Moderator: General Moderators
PHP Novice: Help!: Database connection from script
hi. i've just started learning php and mysql. i can't seem to find out why the script can't connect to database
@ $db = mysql_pconnect('127.0.0.1', 'userid', 'password');
error message indicates it couldn't connect to database. i tried both my ip address, and localhost (as above) to no avail. is it something i have to configure from mysql database?
any help would be appreciated! thanks!
sunny
@ $db = mysql_pconnect('127.0.0.1', 'userid', 'password');
error message indicates it couldn't connect to database. i tried both my ip address, and localhost (as above) to no avail. is it something i have to configure from mysql database?
any help would be appreciated! thanks!
sunny
-
LostMyLove
- Forum Newbie
- Posts: 20
- Joined: Mon Sep 27, 2004 12:20 pm
Code: Select all
$db = mysql_pconnect("localhost", "userid", "password");thank you. i tried but i still have same connection error.
do you think my web server setting isn't correct? i'm not certain if mysql is on the server. i don't think my personal web server(apache) and mysql is connected properly. can u please suggest what i should do to change the configuration?
thank you!
do you think my web server setting isn't correct? i'm not certain if mysql is on the server. i don't think my personal web server(apache) and mysql is connected properly. can u please suggest what i should do to change the configuration?
thank you!
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
You definitely need error handling for most database functions so that you can get much more useful error messages, as Sami said:
Mac
Code: Select all
$db = mysql_pconnect('127.0.0.0', 'userid', 'password') or die(mysql_error());thank you all for the replies!
this is what i wrote exactly...
$dbhost = '127.0.0.1'; //localhost
$dbuser = 'root'; //root as user id for sql server
$dbpass = '*****'; //password for the root
$db = mysql_connect($dbhost, $dbuser, $dbpass) or die("Unable to connect to MySQL"); //this is where the script stops and issue "unable to connect to MySQL"
i also tried to put all the host and user information within parenthesis such as $db = mysql_connect('127.0.0.1', 'root', '*****'); also tried mysql_pconnect().
MySQL version is 4.1, version of php is 5.0.1, and i'm running apache server on windows xp. all of the installations were successful, and all of them runs just fine. i can do database works in MySQL shell, personal web server runs ok and i can parse php scripts without any errors. my firewalls are off also.
this is what i wrote exactly...
$dbhost = '127.0.0.1'; //localhost
$dbuser = 'root'; //root as user id for sql server
$dbpass = '*****'; //password for the root
$db = mysql_connect($dbhost, $dbuser, $dbpass) or die("Unable to connect to MySQL"); //this is where the script stops and issue "unable to connect to MySQL"
i also tried to put all the host and user information within parenthesis such as $db = mysql_connect('127.0.0.1', 'root', '*****'); also tried mysql_pconnect().
MySQL version is 4.1, version of php is 5.0.1, and i'm running apache server on windows xp. all of the installations were successful, and all of them runs just fine. i can do database works in MySQL shell, personal web server runs ok and i can parse php scripts without any errors. my firewalls are off also.
thank you so much!. i've just found out how to fix that problem..phew! finally
because of new hashing algorithm for the password, the older version of my client api wouldn't get authorized with password i specified from the script. i did the following,
mysql> set password for 'staff(userid)'@'127.0.01(localhost)' = OLD_PASSWORD('*****');
and the script works fine now. i can select and insert data without any errors.
thanks!
because of new hashing algorithm for the password, the older version of my client api wouldn't get authorized with password i specified from the script. i did the following,
mysql> set password for 'staff(userid)'@'127.0.01(localhost)' = OLD_PASSWORD('*****');
and the script works fine now. i can select and insert data without any errors.
thanks!