xyn Posted November 23, 2006 Share Posted November 23, 2006 Hi,from my earlier post, i decided to use a for() loopto do the work for me, but i get this error;[color=red]Parse error: syntax error, unexpected T_VARIABLE in /public_html/habbix/dPanel/timetable.php on line 48[/color]my code: line 48 = [color=red]red[/color]<?php for($i=1;$i<24;$i++){ [color=red]$query_$i = mysql_query("SELECT * FROM timetable WHERE day='".strtolower($date)."' AND slot_$i='y'");[/color] if(mysql_num_rows($query_$i) >0){ $s_$i="TAKEN"; }else{ $s_4i="UN-TAKEN"; } } echo (' Link to comment https://forums.phpfreaks.com/topic/28239-for-error/ Share on other sites More sharing options...
Madatan Posted November 23, 2006 Share Posted November 23, 2006 [code]$query_$i = mysql_query("SELECT * FROM timetable WHERE day='strtolower($date)' AND slot_$i='y'");[/code]Could that fix the problem? Link to comment https://forums.phpfreaks.com/topic/28239-for-error/#findComment-129140 Share on other sites More sharing options...
CheesierAngel Posted November 23, 2006 Share Posted November 23, 2006 [quote author=xyn link=topic=116045.msg472623#msg472623 date=1164294030] [color=red]Parse error: syntax error, unexpected T_VARIABLE in /public_html/habbix/dPanel/timetable.php on line 48[/color][/quote]This error indicates there is a variable not recognized.Try to put the $i outside the single quotes. Is the $date variable initialized?[code] $query_$i = mysql_query("SELECT * FROM timetable WHERE day='".strtolower($date)."' AND slot_" . $i . "='y'");[/code] Link to comment https://forums.phpfreaks.com/topic/28239-for-error/#findComment-129141 Share on other sites More sharing options...
xyn Posted November 23, 2006 Author Share Posted November 23, 2006 Parse error: syntax error, unexpected T_VARIABLE in /home/zroxxco/public_html/habbix/dPanel/timetable.php on line 53this line is... same line...$query_$i = mysql_query("SELECT * FROM timetable WHERE day='".strtolower($date)."' AND slot_".$i."='y'"); Link to comment https://forums.phpfreaks.com/topic/28239-for-error/#findComment-129157 Share on other sites More sharing options...
kenrbnsn Posted November 23, 2006 Share Posted November 23, 2006 Turn you query into an array:[code]<?php$query[$i] = mysql_query("SELECT * FROM timetable WHERE day='".strtolower($date)."' AND slot_".$i."='y'");?>[/code]Ken Link to comment https://forums.phpfreaks.com/topic/28239-for-error/#findComment-129171 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.