change coding to (note, each line is enclosed in quotes and ends withn "."):
$query="select user_id, user_name, time, status, comment from users". "where sign=1". "order by user_name". "limit $offset, $step"; print $query; //sanity check...contents of $query $res=mysql_query($query) or die(mysql_error()); //note the die() clause -----Original Message----- From: Web user [mailto:[EMAIL PROTECTED]] Sent: 27 September 2001 05:48 To: [EMAIL PROTECTED] Subject: [PHP-DB] mysql_fetch_array() doesn't work System: PHP4.06 + Mysql3.23.41 Win32 + Apache 1.3.20 Win32 + Win98 When PHP is running at the line: $arr=mysql_fetch_array($res); The IE always show info as below: "Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in c:\program files\apache group\apache\htdocs\web\site1\list.php on line --[the number of line]" What's the problem wiht mysql_fetch_array() or other? What does the T_STRING' or `T_VARIABLE' or `T_NUM_STRING' mean? THANKS Mike The full code below: ------------------------------------------------------------------------ ---- - <? $link=mysql_connect("localhost","",""); if($link==false){ echo "Failed linking to database."; exit(); } $handler=mysql_select_db("database1"); if($handler==false) echo "Failed linking to database."; $query="selct count(*) from users where sign=1"; $res=mysql_query($query); $row=mysql_fetch_row($res); $all=$row[0]; $step=5; $pages=ceil($all/$step); /*the number of pages needed to listed */ if(empty($offset)) $offset=0; $query="select user_id, user_name, time, status, comment from users where sign=1 order by user_name limit $offset, $step"; $res=mysql_query($query); echo "<table><td align=center>User</td> <td align=center>Added time</td><td align=center>Status</td></tr>"; $num=mysql_num_rows($res); for($i=0; $i<$num; $i++) { $arr=mysql_fetch_array($res); /* HERE is line where the error occurs!!! */ echo "<tr><td align=center><a href=\"profile.php?id=$arr['user_id']\" target='_top'> $arr['user_name']</a>></td>"; echo "<td align=center>$arr['time']</td>"; echo "<td align=center>$arr['status']</td></tr>"; echo "<tr colspan=3><td>$arr['comment']</td></tr>"; } echo "</table><br><br><br>"; echo "<table><tr><td align='center'>"; /* show others in multi-pages */ for($i=0; $i<$pages; $i++){ echo "<a href='$PHP_SELF?offset=$i*$step' target='_top'> echo ($i+1)."</a>"; echo " "; } echo "</td></tr></table>"; ?> ------------------------------------------------------------------------ ---- - create table users ( user_id int not null auto_increment primary key, user_name varchar(30), time datetime, status tinyint(1), comment text, sign tinyint(1) default '1' ); -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]