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
Drezek
Forum Newbie
Posts: 3 Joined: Mon Jan 05, 2009 2:57 pm
Post
by Drezek » Mon Jan 05, 2009 2:59 pm
im a big noob and well im trying to select a database after connecting but i have a problem heres the code
Code: Select all
<?php
$connection = mysql_connect('localhost', 'root', 'password');
if (!$connection) {
die('Could not connect: ' . mysql_error());
}
$db_select = mysql_select_db("test", $connection)
if (!$db_select) {
die('database selection failed' . mysql_error());
}
?>
this is the error i get
Parse error: syntax error, unexpected T_IF in C:\xampp\htdocs\sand\connection.php on line 7
VladSun
DevNet Master
Posts: 4313 Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria
Post
by VladSun » Mon Jan 05, 2009 3:00 pm
You missed a semicolon on line 6
There are 10 types of people in this world, those who understand binary and those who don't
Drezek
Forum Newbie
Posts: 3 Joined: Mon Jan 05, 2009 2:57 pm
Post
by Drezek » Mon Jan 05, 2009 3:03 pm
wow i feel like a retard thanks
Drezek
Forum Newbie
Posts: 3 Joined: Mon Jan 05, 2009 2:57 pm
Post
by Drezek » Mon Jan 05, 2009 3:09 pm
Code: Select all
<?php
$result = mysql_query("SELECT * FROM example", $connection);
while ($row = mysql_fetch_array($result)) {
echo $row["name"]. " " .$row["age"];
?>
whats the problem here
error
Parse error: syntax error, unexpected $end in C:\xampp\htdocs\sand\index.php on line 13
LiveFree
Forum Contributor
Posts: 258 Joined: Tue Dec 06, 2005 5:34 pm
Location: W-Town
Post
by LiveFree » Mon Jan 05, 2009 3:12 pm
You need a '}' to end the while() loop