Jump to content

[SOLVED] update SET help


Nothadoth

Recommended Posts

Hey. Im creating a CMS for a website and I have made the textbox to allow the admin to edit the content.

 

The content is submitted through the form and into the var $RTE.

 

This is the code I am using:

 

pageedit = $_GET['edit'];


   $sql = "UPDATE content SET cont = '$RTE' WHERE shortname = $pageedit"; 
   $result = mysql_query($sql);

 

It isn't editting the field.

 

Can someone help?

Link to comment
Share on other sites

Do you get any errors?

 

Try this:

 

pageedit = $_GET['edit'];


   $sql = "UPDATE content SET cont = '$RTE' WHERE shortname = $pageedit"; 
   $result = mysql_query($sql) or die(mysql_error());

 

It will give you a more detailed error from MySQL, if there is any error ofc :)

Link to comment
Share on other sites

Hm...

try this:

$pageedit = $_GET['edit'];


   $sql = "UPDATE content SET cont = '$RTE' WHERE shortname = '$pageedit'"; 
   $result = mysql_query($sql);

 

Also, you said that $RTE comes from form, i guess method is 'post'? $RTE=$_POST[RTE]...

Link to comment
Share on other sites

the error is:

 

Unknown column 'rules' in 'where clause'

 

 

But............ there is a row which has shortname = rules

 

have i done it wrong

 

Your query construct made SQL think you were referring to a COLUMN named rules (that's what the error message said), not that you didn't have a VALUE of rules in the column named shortname.

 

The best way of resolving these types of issue is to have sensible error trapping. Use a syntax similar to the below and tell us exactly what the full error and query are:

 

$sql = " .... whatever your query is ...";
$result = mysql_query($sql) or die("Error: ". mysql_error(). " with query ". $sql); // helpful message

 

 

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.