PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
Cheeseboy
Forum Commoner
Posts: 67 Joined: Thu Mar 23, 2006 2:43 pm
Post
by Cheeseboy » Mon Mar 27, 2006 3:00 pm
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?
josh
DevNet Master
Posts: 4872 Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida
Post
by josh » Mon Mar 27, 2006 6:40 pm
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
Cheeseboy
Forum Commoner
Posts: 67 Joined: Thu Mar 23, 2006 2:43 pm
Post
by Cheeseboy » Mon Mar 27, 2006 6:51 pm
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.
NeoNmaN
Forum Newbie
Posts: 21 Joined: Mon Mar 27, 2006 4:08 am
Location: Denmark
Contact:
Post
by NeoNmaN » Tue Mar 28, 2006 6:02 am
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.