PDA

View Full Version : Can't connect to MySQL database.. Newbie!



jhmisa
05-20-2004, 03:34 AM
Hello I'm new to MySQL and PHP and I've used an exercise in the internet to learn more about it. The tutorial had a db.php and explained that a persistent connection is better to use.. Anyway here's the code. I didn't put my real username and password but I'm sure that the error is not coming from there because I'm able to access PHPMyAdmin using the said username and password. Please help

<?
/* Database Information - Required!! */
/* -- Configure the Variables Below --*/
$dbhost = 'localhost';
$dbusername = 'myusername';
$dbpasswd = 'mypassword';
$database_name = 'users';

/* Database Stuff, do not modify below this line */

$connection = mysql_pconnect("$dbhost","$dbusername","$dbpasswd")
or die ("Couldn't connect to server.");

$db = mysql_select_db("$database_name", $connection)
or die("Couldn't select database.");
?>

jhmisa
05-20-2004, 04:13 AM
silly me.. went and played with PHPMyAdmin and realised that permissions needed to be set to allow access to the database..

wildjokerdesign
05-20-2004, 07:07 AM
Also you can use "root" as the username instead of the one you use to log in to phpMyAdmin and that may have given you the access you wanted without messing with the permissions.

jhmisa
05-20-2004, 10:53 PM
Cheers mate! I'm just sure that I'd need your help again one of these days! keep up the good work!