[thelist] php/mysql and form input...sorta

Roger Harness magic32 at jps.net
Fri Aug 16 02:59:01 CDT 2002


'Volters,

newbie who's trying to follow a book, ("PHP and MySQL Web Development").

I *think* I'm possibly having problems with htmlspecialchars(),
stripslashes(), and addslashes()...or maybe not.

I'm just trying to let the user select a plu number, which will then bring
up a form with that plu's info already filled out in appropriate text boxes,
with each field waiting to be edited if needed. I'm just trying to
semi-reuse my working code for inputting the plu's, and all its
corresponding data fields.

mysql_select_db("roger");
$query = "select * from feeders3 where plu = '$searchterm' order by descr";
$result = mysql_query($query);
$num_results = mysql_num_rows($result);
echo "<p>Number of products found: ".$num_results."</p>\n";
for ($i=0; $i <$num_results; $i++)
{
$row=mysql_fetch_array($result);
echo "<form>\n";
echo "<table>\n";
echo "<tr>\n";
echo "<td>";
echo ($i+1).". Description:</td>\n ";
echo "<td>";
echo htmlspecialchars( stripslashes($row["descr"]));
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>";
echo "Style</td>\n";
echo "<td>";
echo "<input type=text value=".stripslashes($row["style"]).'>';
echo "</td>\n";
echo "</td>\n";

etc etc.

this almost works, except it eats up anything after a space, in any field i
present in an input box.

So my Description (descr) will show fine (e.g. "A-6 Mini Thistle Feeder")
but my Style shows "Mixed" instead of "Mixed Seed"

Does this question make sense? Should I not even be doing it this way?
Again, I'm trying to semi follow the book, and that's probably getting me
into trouble.

as always, tia!

-Roger Harness




More information about the thelist mailing list