Jump to content


Photo

NEED HELP BAD!


  • Please log in to reply
3 replies to this topic

#1 JDWSLIPKNOT

JDWSLIPKNOT
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 22 November 2003 - 03:58 AM

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 4Warning: 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 52Warning: 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 53No Database Selected
Can anyone help me

#2 Arenium

Arenium
  • Staff Alumni
  • Advanced Member
  • 111 posts
  • LocationMassachusetts

Posted 22 November 2003 - 04:53 AM

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.

#3 JDWSLIPKNOT

JDWSLIPKNOT
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 22 November 2003 - 03:28 PM

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.

#4 Arenium

Arenium
  • Staff Alumni
  • Advanced Member
  • 111 posts
  • LocationMassachusetts

Posted 22 November 2003 - 05:57 PM

its included in the zip file at the end of the tut




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users