JDWSLIPKNOT Posted November 22, 2003 Share Posted November 22, 2003 I need to know how to connect to a mysql database. I was working on the membership tutorial on the site and when it says to make a db.php I got stuck this is what i got though <? $db_name = "DBNAME" $connection = @mysql_connection("localhost", "USERNAME", "PASSWORD") or die(mysql_error()); $db = @mysql_select_db($db_name, $connection) or die(mysql_error()); ?> And this is what I get from that Parse error: parse error in /home/virtual/site37/fst/var/www/html/members/db.php on line 4 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/virtual/site37/fst/var/www/html/members/register.php on line 52 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/virtual/site37/fst/var/www/html/members/register.php on line 53 No Database Selected Can anyone help me Quote Link to comment Share on other sites More sharing options...
Arenium Posted November 22, 2003 Share Posted November 22, 2003 did you not see the code there? it should be included at the end of the tut. even so, i\'ll be a nice guy: [php:1:134af6a8f8] <? /* Database Information - Required!! */ /* -- Configure the Variables Below --*/ $dbhost = \'localhost\'; $dbusername = \'xxxxxx\'; $dbpasswd = \'xxxxxxx\'; $database_name = \'xxxxxxx\'; /* 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.\"); // checkuser function function session_checker(){ if(!session_is_registered(\'first_name\')){ include \'login_form.html\'; exit(); } } ?> [/php:1:134af6a8f8] don\'t worry about the second part of that (the session checker function)just yet. Quote Link to comment Share on other sites More sharing options...
JDWSLIPKNOT Posted November 22, 2003 Author Share Posted November 22, 2003 Hey man thanks alot. I did not see it at the end of the tutorial though. Maybe if you can get someone to add it then that would help a lot. Quote Link to comment Share on other sites More sharing options...
Arenium Posted November 22, 2003 Share Posted November 22, 2003 its included in the zip file at the end of the tut Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.