Sorry to do this to you, but I don't know where I've dropped the ball here. When I edit a street address, it won't accept spaces, it only updates the number portion (before the first space) in the database.
Database: Andrews
Table: Info
Field: Street1
Type: TEXT
From a results page, a user selects a single record to edit, the record is displayed on this edit1.php page using the unique record number. The submit button sends the information to edit.php
QUESTION: How can I get my php code to accept the spaces in the street field for updating?
Thanks.
/ EDIT1.PHP /
<?php
mysql_connect("server", "name", "pass");
mysql_select_db("Andrews");
$num = $HTTP_POST_VARS['num'];
$query = ("SELECT * FROM Info WHERE num = '$num'");
$data = mysql_query($query);
echo "<table name='results' border='1' cellpadding='0'>";
echo "<tr>";
echo "<td><b>Change?</td>";
echo "<td><b>First</td>";
echo "<td><b>Last</td>";
echo "<td><b>Street</td>";
echo "<td><b>City</td>";
echo "<td><b>State</td>";
echo "<td><b>Zip</td>";
echo "<td><b>Email<td></tr>";
echo "<form action=edit.php method=post>";
while($d = mysql_fetch_array($data)) {
$vnum = $d[num];
$vfirst = $d[First];
$vlast = $d[Last];
$vstreet1 = $d[Street1];
$vcity = $d[City];
$vstate = $d[State];
$vzip = $d[Zip];
$vemail = $d[Email];
echo "<tr><td><input type=submit value=$num name=num></td>";
echo "<td><input type=text name=first value=$vfirst></td>";
echo "<td><input type=text name=last value=$vlast></td>";
echo "<td><input type=text name=street value=$vstreet1></td>";
echo "<td><input type=text name=city value=$vcity></td>";
echo "<td><input type=text name=state value=$vstate></td>";
echo "<td><input type=text name=zip value=$vzip></td>";
echo "<td><input type=text name=email value=$vemail></td></tr>";
}
echo "</form>";
/ EDIT.PHP /
<?php
mysql_connect("localhost", "mandrews", "3ll1s")
or die("Could not connect.");
mysql_select_db("Andrews") or die("Could not select database");
$first = $HTTP_POST_VARS['first'];
$last = $HTTP_POST_VARS['last'];
$street = $HTTP_POST_VARS['street'];
$city = $HTTP_POST_VARS['city'];
$state = $HTTP_POST_VARS['state'];
$zip = $HTTP_POST_VARS['zip'];
$email = $HTTP_POST_VARS['email'];
$update = ("UPDATE Info Set First='$first', Last='$last', Street1='$street', City='$city', State='$state', Zip='$zip', Email='$email' WHERE num='$num'");
mysql_query($update)
or die(mysql_error());
echo "$first $last updated.<br>";
echo "<a href=search.html>Return to search screen</a>";
echo "<br><a href=www.ellisandrews.org>Home</a>";