Jump to content

Update


ecabrera

Recommended Posts

Here's a problem: <input type='hidden' name='saveedit' value='$newid'/> You didn't echo the value of the variable in the value= attribute, therefore the value is the string literal '$newid'. That is probably the major part of this issue, since none of your records will have '$newid' as the value of the primary key.

Link to comment
Share on other sites

Pikachu2000 is right this has nothing to do with update problem i tred checking my code alot of times but i can figure it out when i update it says update succesfull but it doesnt even updates

 

Well you said it says it updates, but it doesn't change anything. So maybe your variables are confused. At the top of your code, to have assigned the old data the the same variables you assigned the new data too. Maybe its just that instead of sending the new data, it is sending the old data instead. Its worth changing the variable names just to be sure

Link to comment
Share on other sites

lets get back on topic, pickachu stated why the $msg error is occurring, this leads the error to be in the update query, can you post your new query code please.

 

it says update successful because you have not checked the validity of your query before outputting that sentence.. what you should be doing is only outputting that if the query returns true..

 

$query = mysql_query("UPDATE news SET title='$newstitle', `by`='$newsby', body='$newsbody' WHERE id='$newid'");

if($query)
      echo "UPDATE SUCCESFULLY!";
else
       die(mysql_error());

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.