Thanks Devin. That worked. I had to change the $POST to $GET.
Now the page displays the record to be edited, but when clicking my update button I receive the error:
mysql_fetch_array(): supplied argument is not a valid MySQL result resource in editform.php on line 64
My line 64 is: $row = mysql_fetch_array($ret);
(Basically, this page displays a selected record, you make a modification the the record and it saves back to the database. Probably extremely simple to fix, but being new to PHP, it's making me nuts!)
Here is the complete code on this page I'm trying to fix.
<?
$usr = "ttsuser";
$pwd = "tts";
$db = "tts_competitors";
$host = "hawk";
#connect to database
$cid = mysql_connect($host,$usr,$pwd);
if (!$cid) { echo("ERROR: " . mysql_error() . "\n"); }
?>
<?
processed when form is submitted back onto itself
if ($REQUEST_METHOD=="POST") {
# setup SQL statement
$SQL = " UPDATE competitor SET";
$SQL = $SQL . " Company = '$Company', ";
$SQL = $SQL . " Web = '$Web', ";
$SQL = $SQL . " Phone = '$Phone', ";
$SQL = $SQL . " Address = '$Address', ";
$SQL = $SQL . " City = '$City', ";
$SQL = $SQL . " St = '$St', ";
$SQL = $SQL . " Cty = '$Cty', ";
$SQL = $SQL . " Zip = '$Zip', ";
$SQL = $SQL . " Services = '$Services', ";
$SQL = $SQL . " Focus = '$Focus', ";
$SQL = $SQL . " Workedwith = '$Workedwith' ";
$SQL = $SQL . " WHERE recnum = $recnum ";
# execute SQL statement
$result = mysql_db_query($db,"$SQL",$cid);
# check for errors
if (!$result) { echo("ERROR: " . mysql_error() . "\n$SQL\n"); }
echo ("<P><B>Record Updated</B></P>\n");
}
else
{
display the edit part of the form.
setup SQL statement to retrieve link that we want to edit.
$SQL = 'SELECT * FROM competitor WHERE recnum = ' . $_GET['recnum'];
# execute SQL statement
$ret = mysql_db_query($db,$SQL,$cid);
# retrieve values
$row = mysql_fetch_array($ret);
$Company = $row["Company"];
$Web = $row["Web"];
$Phone = $row["Phone"];
$Address = $row["Address"];
$City = $row["City"];
$St = $row["St"];
$Cty = $row["Cty"];
$Zip = $row["Zip"];
$Services = $row["Services"];
$Focus = $row["Focus"];
$Workedwith = $row["Workedwith"];
?>
<FORM NAME="fa" ACTION="editform.php" METHOD="POST">
<INPUT TYPE="hidden" NAME="recnum" VALUE="<? echo("$recnum"); ?>">
<TABLE>
<TR><TD><B>Company: </B> </TD><TD><INPUT TYPE="text" NAME="Company" VALUE="<? echo("$Company"); ?>" SIZE=40></TD></TR>
<TR><TD><B>Web:</B> </TD><TD><INPUT TYPE="text" NAME="Web" VALUE="<? echo("$Web"); ?>" SIZE=40></TD></TR>
<TR><TD><B>Phone:</B> </TD><TD><INPUT TYPE="text" NAME="Phone" VALUE="<? echo("$Phone"); ?>" SIZE=40></TD></TR>
<TR><TD><B>Address:</B> </TD><TD><INPUT TYPE="text" NAME="Address" VALUE="<? echo("$Address"); ?>" SIZE=40></TD></TR>
<TR><TD><B>City:</B> </TD><TD><INPUT TYPE="text" NAME="City" VALUE="<? echo("$City"); ?>" SIZE=40></TD></TR>
<TR><TD><B>State:</B> </TD><TD><INPUT TYPE="text" NAME="St" VALUE="<? echo("$St"); ?>" SIZE=40></TD></TR>
<TR><TD><B>Country:</B> </TD><TD><INPUT TYPE="text" NAME="Cty" VALUE="<? echo("$Cty"); ?>" SIZE=40></TD></TR>
<TR><TD><B>Zip:</B> </TD><TD><INPUT TYPE="text" NAME="Zip" VALUE="<? echo("$Zip"); ?>" SIZE=40></TD></TR>
<TR><TD><B>Services: </B> </TD><TD><TEXTAREA NAME="Services" ROWS=5 COLS=40><? echo("$Services"); ?></TEXTAREA></TD></TR>
<TR><TD><B>Focus: </B> </TD><TD><TEXTAREA NAME="Focus" ROWS=5 COLS=40><? echo("$Focus"); ?></TEXTAREA></TD></TR>
<TR><TD><B>Worked With: </B> </TD><TD><TEXTAREA NAME="Approved" ROWS=5 COLS=40><? echo("$Workedwith"); ?></TEXTAREA></TD></TR>
<TR><TH COLSPAN=2><P><INPUT TYPE="submit" VALUE="Update"></P></TH></TR>
</TABLE>
</FORM>
<? }
mysql_close($cid);
?>