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
https://forums.phpfreaks.com/topic/58935-solved-update-set-help/
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 :)

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

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.