PDA

View Full Version : something wrong with loop



GO ILLINI
06-21-2006, 06:31 AM
Parse error: parse error, unexpected '\"', expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\server\xampp\htdocs\cfg\adverts.php on line 20



$i = 0;
while($i < $line_num) {

echo "$_POST[" . $i . "]";


$i++;
} I dont see anything wrong with that. The form I am almost certian is all right but here it is too



<form action='adverts.php?action=edit' method='post'>
<p>
Edit current adverts:<br>
<table>
<?php
$lines = file("$cstrike\cfg\mani_admin_plugin\adverts.txt");
foreach ($lines as $line_num => $line) {
echo "<tr><td>$line</td>\n";
echo "<td><input type='text' value='$line' name='$line_num'></td></tr>\n";
}
?>
<input type='hidden' name='lines' value=<?php echo($line_num); ?>>
<tr><td colspan='2'><center><input type='submit' value='Submit Changes'></center></td></tr>
</table>
</p>
</form>
The form returns everything exactly as it should be.
Output of form:

<form action='adverts.php?action=edit' method='post'>
<p>
Edit current adverts:<br>
<table>
<tr><td>{RED}http://www.mani-admin-plugin.com
</td>
<td><input type='text' value='{RED}http://www.mani-admin-plugin.com
' name='0'></td></tr>
<tr><td>{GREEN}Current map is {CURRENTMAP}
</td>
<td><input type='text' value='{GREEN}Current map is {CURRENTMAP}
' name='1'></td></tr>
<tr><td>{BLUE}Mani Admin Plugin
</td>
<td><input type='text' value='{BLUE}Mani Admin Plugin
' name='2'></td></tr>
<tr><td>Next map is {NEXTMAP}
</td>
<td><input type='text' value='Next map is {NEXTMAP}
' name='3'></td></tr>
<tr><td>{WHITE}Server Tick Rate {TICKRATE}
</td>
<td><input type='text' value='{WHITE}Server Tick Rate {TICKRATE}
' name='4'></td></tr>
<tr><td>hgsdg
</td>
<td><input type='text' value='hgsdg
' name='5'></td></tr>
<tr><td>adam</td>
<td><input type='text' value='adam' name='6'></td></tr>
<input type='hidden' name='lines' value=6>
<tr><td colspan='2'><center><input type='submit' value='Submit Changes'></center></td></tr>
</table>
</p>
</form>
Anybody help please? Sorry about all the code, but people ask for it and I didnt wanna leave anything out.

The one and only,
ILLINI

lavinpj1
06-21-2006, 08:06 AM
echo "$_POST[" . $i . "]"; is wrong. Should be echo $_POST[$i];

~Phil~

GO ILLINI
06-21-2006, 06:15 PM
No errors now, but there is nothing there...


The one and only,
ILLINI

GO ILLINI
06-21-2006, 10:11 PM
It is because of the loop. Nothing echos from inside it.
I tried echoing the post vars outside of the loop, and they showed up fine.
any help?


The one and only,
ILLINI