Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Weird POST problem - removes first 4 chars!

Status
Not open for further replies.

rastkocvetkovic

Programmer
Aug 11, 2002
63
SI
Well, I'm just asking if somebody has run into similar problems.

I'll simplify it.
I have first.php with form named "value", and submit which redirects to second.php. On the second, I retrieve the "value" and first 4 chars are removed. I tried both POST and GET, and it's funny with GET - attention - in the URL, shown above the "value" is full ('?value=independence'), but in the page the $_GET['value'] has first 4 chars chopped ('pendence').

What could be the problem or is it a PHP bug?
 
full code is always useful in situations like this :) ______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
OK, here's the code from first.php

---------------------------

<form action=&quot;second.php&quot; method=&quot;GET&quot;>

<?
$result = mysql_query (&quot;SELECT id,food,description,price,order FROM Offer_food&quot;);
$j=1;
while ($row = mysql_fetch_array ($result)) {
?>
<table width=&quot;506&quot; border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;>
<tr class=&quot;podpodnaslov3&quot;>
<td width=&quot;35&quot;>
<?=($i+1)?>.<input type=&quot;text&quot; name=&quot;order[]&quot; value=&quot;<?=$row[&quot;order&quot;]?>&quot; style=&quot;width: 20; height: 18; font-size: 11px; font-weight: bold&quot;>
</td>
<td width=&quot;381&quot; align=&quot;left&quot; valign=&quot;top&quot;>
<input type=&quot;text&quot; name=&quot;food[]&quot; value=&quot;<?=$row[&quot;food&quot;]?>&quot; style=&quot;width: 150; height: 18; font-size:11px; font-weight: bold&quot;>
<input type=&quot;hidden&quot; name=&quot;offer_id[]&quot; value=&quot;<?=$row[&quot;id&quot;]?>&quot;>
</td>
<td width=&quot;90&quot; align=&quot;left&quot; valign=&quot;top&quot;>
<input type=&quot;text&quot; name=&quot;price[]&quot; value=&quot;<?=$row[&quot;price&quot;]?>&quot; style=&quot;width: 40; height: 18; font-size: 11px&quot;> SIT
</td>
</tr>
<tr class=&quot;podvsebina3&quot;>
<td>&nbsp;</td>
<td align=&quot;left&quot; valign=&quot;top&quot;>
<input name=&quot;description[]&quot; type=&quot;text&quot; id=&quot;description[]&quot; style=&quot;width: 200; height: 18; font-size:10px&quot; value=&quot;<?=$row[&quot;description&quot;]?>&quot;>
</td>
<td align=&quot;left&quot;>
<input type=&quot;checkbox&quot; name=&quot;checkbox[<?=$j_1?>]&quot;>briši
</td>
</tr>
<tr>
<td height=&quot;10&quot;><img src=&quot;<?=$path?>_images/blanks/transparent1x1.gif&quot; width=&quot;35&quot; height=&quot;10&quot;></td>
<td height=&quot;10&quot;><img src=&quot;<?=$path?>_images/blanks/transparent1x1.gif&quot; width=&quot;1&quot; height=&quot;1&quot;></td>
<td height=&quot;10&quot;><img src=&quot;<?=$path?>_images/blanks/transparent1x1.gif&quot; width=&quot;1&quot; height=&quot;10&quot;><img src=&quot;<?=$path?>_images/blanks/transparent1x1.gif&quot; width=&quot;1&quot; height=&quot;1&quot;></td>
</tr>
</table>
<?
$j++;
$j_1++;
}
?>
</form>

---------------------------

Here's second.php


<?
print_r($HTTP_GET_VARS);
?>

---------------------------

In the browsers URL - localhost/second.php?variable=12345678

All the variables in the arrays have first 4 chars removed.
variable, if we echo, the PHP outputs - 5678.

Clearer now?
 
the only thing I had to change was the &quot;order&quot; COLUMN IN MYSQL , this is a reserved word for uk/us english version.

seems to work just fine other than that

<?
$user=root;
$host=localhost;
$password=&quot;&quot;;

$db=@mysql_connect($host,$user,$password) ;

mysql_checkerror();

@mysql_select_db(&quot;Offer_food&quot;,$db) ;

mysql_checkerror();


$result = mysql_query(&quot;SELECT id,food,description,price,ordnum FROM Offer_food&quot;,$db);
mysql_checkerror();
$j=1;
while ($row = mysql_fetch_array ($result)) {
?>
<form method=POST action=next.php>
<table width=&quot;506&quot; bordnum=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;>
<tr class=&quot;podpodnaslov3&quot;>
<td width=&quot;35&quot;>
<input type=&quot;text&quot; name=&quot;ordnum[]&quot; value=&quot;<?=$row[&quot;ordnum&quot;]?>&quot; style=&quot;width: 20; height: 18; font-size: 11px; font-weight: bold&quot;>
</td>
<td width=&quot;381&quot; align=&quot;left&quot; valign=&quot;top&quot;>
<input type=&quot;text&quot; name=&quot;food[]&quot; value=&quot;<?=$row[&quot;food&quot;]?>&quot; style=&quot;width: 150; height: 18; font-size:11px; font-weight: bold&quot;>
<input type=&quot;hidden&quot; name=&quot;offer_id[]&quot; value=&quot;<?=$row[&quot;id&quot;]?>&quot;>
</td>
<td width=&quot;90&quot; align=&quot;left&quot; valign=&quot;top&quot;>
<input type=&quot;text&quot; name=&quot;price[]&quot; value=&quot;<?=$row[&quot;price&quot;]?>&quot; style=&quot;width: 40; height: 18; font-size: 11px&quot;> SIT
</td>
</tr>
<tr class=&quot;podvsebina3&quot;>
<td> </td>
<td align=&quot;left&quot; valign=&quot;top&quot;>
<input name=&quot;description[]&quot; type=&quot;text&quot; id=&quot;description[]&quot; style=&quot;width: 200; height: 18; font-size:10px&quot; value=&quot;<?=$row[&quot;description&quot;]?>&quot;>
</td>
<td align=&quot;left&quot;>
<input type=&quot;checkbox&quot; name=&quot;checkbox[<?=$j_1?>]&quot;>briši
</td>
</tr>
<tr>
<td height=&quot;10&quot;><img src=&quot;<?=$path?>_images/blanks/transparent1x1.gif&quot; width=&quot;35&quot; height=&quot;10&quot;></td>
<td height=&quot;10&quot;><img src=&quot;<?=$path?>_images/blanks/transparent1x1.gif&quot; width=&quot;1&quot; height=&quot;1&quot;></td>
<td height=&quot;10&quot;><img src=&quot;<?=$path?>_images/blanks/transparent1x1.gif&quot; width=&quot;1&quot; height=&quot;10&quot;><img src=&quot;<?=$path?>_images/blanks/transparent1x1.gif&quot; width=&quot;1&quot; height=&quot;1&quot;></td>
</tr>
</table>
<?
$j++;
$j_1++;
}

// functions

function mysql_checkerror(){

$err_no=mysql_errno();

if ($err_no > 0 ){

echo &quot;<h2> Error:</h1> &quot; . mysql_errno() . &quot;: &quot; . mysql_error() . &quot;<br>\n&quot;;

exit;

}
}

?>
<input type=submit name=submit value=submit>
</form> ______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top