Re: [PHP] mysql_fetch_array() doesn't work
echo a href='$PHP_SELF?offset=$i*$step' target='_top' Missing end quote and semicolon on this line may be the reason... Try properly indenting and formatting your code. Also take advantage of going in and out of php mode to seperate your code from your display of content... Ex: instead of this: ? echo(td align=\center\ width=\$nWidth\$sContent/td); ? Try this: td align=center width=? echo($nWidth); ?? echo($sContent); ?/td Or even this: td align=center width=?=$nWidth??=$sContent?/td It makes it MUCH easier to read and maintain, and seperates the PHP code from the HTML content as much as possible. Any questions, please ask me. -Jason Garber Lead Programmer - www.pulseaday.com [EMAIL PROTECTED] --- At 12:48 PM 9/27/2001 +0800, you wrote: 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 tabletd align=centerUser/td td align=centerAdded time/tdtd align=centerStatus/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 trtd align=centera 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=3td$arr['comment']/td/tr; } echo /tablebrbrbr; echo tabletrtd 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 nbsp;nbsp;; } 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 General 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]
Re: [PHP] mysql_fetch_array() doesn't work
Hi Mike, The query $query=selct count(*) from users where sign=1; should be select not selct -and in future to know if there is any error in your queries you might want to check this way: if(mysql_query($query) { --do statements-- } else -error msg- or even the following would be a convenient way to get your recordset and check for invalid query. just try this $result = mysql_query (SELECT my_col FROM my_tbl) or die (Invalid query); IN YOUR CASE try: $res=mysql_query($query) or die (Invalid query); and let me know if you still have a problem. -Naintara - Original Message - From: Web user [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, September 27, 2001 10:18 AM Subject: [PHP] 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 tabletd align=centerUser/td td align=centerAdded time/tdtd align=centerStatus/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 trtd align=centera 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=3td$arr['comment']/td/tr; } echo /tablebrbrbr; echo tabletrtd 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 nbsp;nbsp;; } 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 General 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 General 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] 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 tabletd align=centerUser/td td align=centerAdded time/tdtd align=centerStatus/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 trtd align=centera 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=3td$arr['comment']/td/tr; } echo /tablebrbrbr; echo tabletrtd 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 nbsp;nbsp;; } 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 General 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]
Re: [PHP] mysql_fetch_array() doesn't work
hi. this doesn't have to do with mysql_fetch_array. the following will create that error : echo a $b['c'] d e f; the following will not : echo a $b[c] d e {$f['g']} h i $j[$k] l 'm' n o p; adjust accordingly. just posted a few words on this topic recently, can view them here : http://marc.theaimsgroup.com/?l=php-generalm=100152166602273 regards, Philip Olson On Thu, 27 Sep 2001, Web user wrote: 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 tabletd align=centerUser/td td align=centerAdded time/tdtd align=centerStatus/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 trtd align=centera 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=3td$arr['comment']/td/tr; } echo /tablebrbrbr; echo tabletrtd 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 nbsp;nbsp;; } 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 General 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 General 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] mysql_fetch_array() doesn't work
System: PHP4.06 + Mysql3.23.41 Win32 + Apache 1.3.20 Win32 + Win98 ? .. .. $res=mysql_query($query); $num=mysql_num_rows($res); for($i=0; $i$num; $i++){ $arr=mysql_fetch_array($res); ... } ... 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\...\page.php on line ... What's the problem wiht mysql_fetch_array() or other? Thanks! Mike -- PHP General 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]