Hi,
I have the following code that places a table entry in a form, allows me to edit it, and supposedly allows the table to be updated when I hit Submit. However, that part doesn't work. Here's the code :
<?php
$HTTP_GET_VARS['table'];
$HTTP_GET_VARS['ID'];
$db = mysql_connect("localhost", "outdoor");
mysql_select_db("Outdoors",$db);
if ($submit) {
$sql = "INSERT INTO Testinput (URL,SiteName,Description,Subcategory,Location,Status) VALUES (´$url´,´$sitename´,´$description´,´$subcategory´,´$location´,´$status´) WHERE ID=$ID";
}
?>
<form method="post" action="<?php echo $PHP_SELF?>">
<?php
if ($id) {
// editing so select a record
$sql = "SELECT * FROM $table WHERE ID=$ID";
$result = mysql_query($sql);
$myrow = mysql_fetch_array($result);
$id = $myrow["ID"];
$url = $myrow["URL"];
$sitename = $myrow["SiteName"];
$description = $myrow["Description"];
$subcategory = $myrow["SubCategory"];
$location = $myrow["Location"];
$status = $myrow["Status"];
// print the id for editing
?>
<input type=hidden name="ID" value="<?php echo $ID ?>">
<?php
}
?>
URL:<input type="Text" name="URL" value="<?php echo $url ?>"><br>
SiteName:<input type="Text" name="SiteName" value="<?php echo $sitename ?>"><br>
Description:<input type="Text" name="Description" value="<?php echo $description ?>"><br>
SubCategory:<input type="Text" name="SubCategory" value="<?php echo $subcategory ?>"><br>
Location:<input type="Text" name="Location" value="<?php echo $location ?>"><br>
Status:<input type="Text" name="Status" value="<?php echo $status ?>"><br>
<input type="Submit" name="submit" value="Enter information">
</form>
Here's the error that I get :
Warning: 0 is not a MySQL result index in /usr/local/etc/httpd/htdocs/editRecord.php3 on line 17
Here's the URL that I use to call the script in the first place :
editRecord.php3?table=Testinput&ID=2
So, by question in, why won't the entry get edited?
Thanks for the help!
Mark