[thelist] HTTP_POST_VARS truncating data

Santilal Parbhu santilal at scorpioneng.co.nz
Wed Dec 3 17:29:38 CST 2008



I am developing an application where the user selects an item from the
drop-down menu.  When I receive the form data using the POST method, it
seems to truncate the data when a space is encountered.  I am using php4,
and mysql, but I am not sure of the version.  


The menu is populated from a mysql database, using the code below:


print '<p>Select Team: <select name="team"></p>';

                                    print'<form action="viewdraw2.php"

<p>Select Team: <select name="team"></p>';

                                    $query = "SELECT DISTINCT team_name FROM
$compteams ORDER BY team_name ";

                                    if (@mysql_query($query)) {

                                                $r = mysql_query($query);

                                                while ($row =
mysql_fetch_row($r)) {

                                                $rrow = $row[0];

                                                print "<option

                                                print" $rrow</option>";



                                                <input type="submit"
name="select" value="Use this selection!" id="submitbutton" />




                                    //Query not successful.

                                    print "<p>Could not retrieve the entry
because: <b>" . mysql_error() . "</b>. The query was $query.</p>";




This part works fine.


The receiving script is:

$selection = $HTTP_POST_VARS['selection'];

            $select = $HTTP_POST_VARS['select'];

            $md = $HTTP_POST_VARS['matchdate'];

            $team = ereg_replace(" ", "%20",
$HTTP_POST_VARS['team']);//Added to stop the space in team names causing

            //$team = $string;

            $team2 = $HTTP_POST_VARS['team'];

            print "Matchdate = $md, Radio = $selection, Date = $select, Team
= $team2, TeamChanged = $team";//Print this out to debug truncating problem



Some of the team names are two part names, e.g Water Boys.  When I print out
$team2 I only get "Water", i.e. the "boys" is truncated off.  The code works
fine if the team name has no spaces.


I have inserted the $team = ereg_replace(" ", "%20",
$HTTP_POST_VARS['team']); to try this as someone told me this would solve my
problem, but it didn't.  


Please note that I have cut and paste the code into this email, so it might
be incomplete syntax-wise as this is just a small part of a bigger script,
but the code does work except for the problem mentioned.






More information about the thelist mailing list