Nothadoth Posted July 8, 2007 Share Posted July 8, 2007 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 More sharing options...
Wuhtzu Posted July 8, 2007 Share Posted July 8, 2007 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 https://forums.phpfreaks.com/topic/58935-solved-update-set-help/#findComment-292444 Share on other sites More sharing options...
sinisake Posted July 8, 2007 Share Posted July 8, 2007 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 https://forums.phpfreaks.com/topic/58935-solved-update-set-help/#findComment-292445 Share on other sites More sharing options...
Nothadoth Posted July 8, 2007 Author Share Posted July 8, 2007 the error is: Unknown column 'rules' in 'where clause' But............ there is a row which has shortname = rules have i done it wrong Link to comment https://forums.phpfreaks.com/topic/58935-solved-update-set-help/#findComment-292716 Share on other sites More sharing options...
hackerkts Posted July 8, 2007 Share Posted July 8, 2007 Hmm.. Are you sure there's a rules in your shortname column? The error shown doesn't seem to agree with that. Link to comment https://forums.phpfreaks.com/topic/58935-solved-update-set-help/#findComment-292730 Share on other sites More sharing options...
AndyB Posted July 8, 2007 Share Posted July 8, 2007 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 https://forums.phpfreaks.com/topic/58935-solved-update-set-help/#findComment-292740 Share on other sites More sharing options...
Nothadoth Posted July 9, 2007 Author Share Posted July 9, 2007 thanks, i just changed it to the id field as opose to shortname. works now Link to comment https://forums.phpfreaks.com/topic/58935-solved-update-set-help/#findComment-292774 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.