Page 1 of 1

mysql connect error

Posted: Mon Mar 27, 2006 3:00 pm
by Cheeseboy
Hi, I am using this code to connect:

Code: Select all

<?php
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
   die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);
?>
And when i try it out it gives me the error.

Parse error: parse error, unexpected T_EXIT in /var/www/Esgames4uweb/phpinfo.php on line 4



Whats wrong with it? i got it straight from the site?

Re: mysql connect error

Posted: Mon Mar 27, 2006 6:40 pm
by josh

Code: Select all

<?php
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
   exit('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);
?>

try this, its perfectly valid code though

Posted: Mon Mar 27, 2006 6:51 pm
by Cheeseboy
once again i get a error in my code on line2. Is there something i need to edit in the php.ini? Im using linux. So the ; trick i dont think will work as told be friends.

Posted: Tue Mar 28, 2006 6:02 am
by NeoNmaN
remeber to change the username, pass and host to you if you not hav to doe ist will make a error if you test it local try

user: root
pass:
host: localhost

database: you most crate one and typet it in.