PDA

View Full Version : whats wrong with my code. please help me?



wispas
February 20th, 2007, 10:28 PM
I got this code off a tutorial - copy and paste. look what it gives me. Please help me and tell me whats wrong.

<?
// Connect database
include("connectdb.php");

// Get all records in all columns from table and put it in $result.
$result=mysql_query("select * from phonebook");

/*Split records in $result by table rows and put them in $row.
Make it looping by while statement. */
while($row=mysql_fetch_assoc($result)){

// Output
echo "ID : $row['id']
";
echo "Name : $row['name']
";
echo "Email : $row['email']
";
echo "Tel : $row['tel'] ";
}

mysql_close();
?>

Error Message:
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /homepages/44/d195205520/htdocs/freezer/select.php on line 13

bwh2
February 20th, 2007, 10:34 PM
remove those line breaks. ex:

echo "ID : $row['id']";

wispas
February 20th, 2007, 10:51 PM
It works. Thank you!

bwh2
February 20th, 2007, 10:54 PM
no problem. also, if you want to make it prettier and faster, use single quotes with concatenation:


echo 'ID : '.$row['id'];

wispas
February 20th, 2007, 10:57 PM
no problem. also, if you want to make it prettier and faster, use single quotes with concatenation:


echo 'ID : '.$row['id'];


I see. Thank you!