Page 1 of 1

Query Help

Posted: Sat Apr 02, 2005 3:10 am
by Smackie
hey i am trying to query one of my databases and i keep getting an error

here is the code..

Code: Select all

<?php

if (!$link = mysql_connect('mysql_host', 'mysql_user', 'mysql_password')) {
   echo 'Could not connect to mysql';
   exit;
}

if (!mysql_select_db('mysql_dbname', $link)) {
   echo 'Could not select database';
   exit;
}

$sql    = 'SELECT * FROM chat WHERE id = 0';
$result = mysql_query($sql, $link);

if (!$result) {
   echo "DB Error, could not query the database\n";
   echo 'MySQL Error: ' . mysql_error();
   exit;
}

while ($row = mysql_fetch_assoc($result)) {
   echo $row['chat'];
}

mysql_free_result($result);

?>
here is the error im getting
Parse error: parse error, unexpected T_STRING in chat.php on line 6
can someone see whats wrong because i cant see anything wrong

Posted: Sat Apr 02, 2005 5:07 am
by n00b Saibot
change

Code: Select all

if (!$link = mysql_connect('mysql_host', 'mysql_user', 'mysql_password'))
to

Code: Select all

$link = mysql_connect('mysql_host', 'mysql_user', 'mysql_password');
if (!$link) {