My host recently “hardened up” PHP and I ended up having to re-write my code to use the “GET” method for updating my database. Things have been ok except that I have a requirement to upload largeish amounts of text and I have found that because GET sends the data added to a url sometimes the url is too long.
So… I have been trying to use $_POST. Basically, I have just taken the code that worked using GET and replaced GET with POST. Now I get the following error:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /xxx/yyy/zzz/admin/edit_category.php on line 18
Here is the code:
<?php
$catID = $_POST['catID'];
$submit = $_POST['submit'];
$category = $_POST['category'];
echo "catID: $catID";
if ($submit) {
$sql = "UPDATE mm_category SET category='$category' WHERE catID=$catID";
$result = mysql_query($sql);
echo "<p>Category name has been changed to: <b>$category</b></p>\
";
} else {
// query the DB
$sql = "SELECT * FROM mm_category WHERE catID=$catID";
$result = mysql_query($sql);
$myrow = mysql_fetch_array($result);
?>
<form method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>">
<input type=hidden name="catID" value="<?php echo $myrow["catID"] ?>">
<input type="Text" name="category" value="<?php echo $myrow["category"] ?>"> <b>Category Name</b><br />
<br /><input type="Submit" name="submit" value="Submit Update">
</form>
<?php
}
?>
btw, I have tried adding single quotes to ‘$catID’. The error stops but no data is passed on.
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/worldcap/public_html/db-missionmap/admin/edit_category.php on line 27 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘’ at line 1
Not sure what that means. But my problems did start after my host “hardened up” PHP.
Immerse and sbarrat, many thanks for your help.
I am looking forward to trying your suggestions… I won’t be able to access the code until I return to my office on Monday. I will let you know how it goes.
Doing a “harden up” on PHP has definitely made things harder…