Jump to content

mySQL UPDATE function


a1amattyj

Recommended Posts

Hi,

 

Im currently in the process of making an administration panel. I want admins to be able to add comments to each "report". So, after submitting the text to a form, it directs to the following code..

 

<?
if($_GET['id'] && $_GET['comment'] && !$_GET['email'] && !$_GET['mail']){
require("config.php");
$id = $_GET['id'];
$query = "SELECT * FROM reports WHERE id='$id'";
$comments = $_POST['comments'];
$result = mysql_query("UPDATE reports SET admin_comments='$comments' WHERE comments='NULL'") 
or die(mysql_error());  
$row = mysql_fetch_array( $result );
}
?>

 

I get this error :

 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/easyfor1/public_html/report/admin/report_list.php on line 454

 

 

Finally, is it possible that the update ADD's to what is already in the field?

 

Thanks

Link to comment
Share on other sites

You get an error because you can't fetch an array from an update query.

 

if you want to add to whats there

$id = $_GET['id'];
$query = "SELECT * FROM reports WHERE id='$id'";
$res = mysql_query($query) or die(mysql_error());
$r = mysql_fetch_assoc($res);
$comments = stripslashes($r['admin_comments'];
$comments .= "\n ".addslashes($_POST['comments']);
$result = mysql_query("UPDATE reports SET admin_comments='$comments' WHERE comments='NULL'") or die(mysql_error()); 

 

Ray

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.