Page 1 of 1

trying to connect to database

Posted: Thu Nov 24, 2005 4:14 pm
by gaogier
Parse error: parse error, unexpected T_LOGICAL_OR in /home/gaming/mysql_connect1.php on line 4

thats the error

heres the code

Code: Select all

<?php

$dbcnx = mysql_connect("localhost", "gaming_phpbb1", "password");
  or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("gaming_phpbb1");

function escape_data1 ($data){
	global $dbh;
	if (ini_get('magic_quotes_gpc')){
		$data = stripslashes($data);
	}
	return mysql_real_escape_string (trim ($data), $dbh);
}

?>
where have i gone wrong?

Posted: Thu Nov 24, 2005 4:18 pm
by neophyte

Code: Select all

<?php

$dbcnx = mysql_connect("localhost", "gaming_phpbb1", "password")
  or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("gaming_phpbb1");

function escape_data1 ($data){
   global $dbh;
   if (ini_get('magic_quotes_gpc')){
      $data = stripslashes($data);
   }
   return mysql_real_escape_string (trim ($data), $dbh);
}

?>
There was an extra semicolon in your mysql_connect statement.

See if that works.

Posted: Thu Nov 24, 2005 4:24 pm
by gaogier
now its this error

Warning: mysql_connect(): Access denied for user: 'gaming_phpbb1@localhost' (Using password: YES) in /home/gaming/mysql_connect1.php on line 3
I cannot connect to the database because: Access denied for user: 'gaming_phpbb1@localhost' (Using password: YES)

Posted: Thu Nov 24, 2005 4:25 pm
by neophyte
Make sure you have the right username and password for your database. I hope your password is not password but if it's not don't post. I think I might have done that once.... :oops:

Posted: Thu Nov 24, 2005 4:26 pm
by gaogier
i changed it, to password so i can show you guys

i addded a new user to it, and it now works thanks