0

I'm following the PHP tutorial from Lynda. I got to the update part of the tutorial but my code won't execute the page simply reloads. I can't seem to figure it out.

$id = mysql_prep($_GET['subj']);
$menu_name = mysql_prep($_POST['menu_name']);
$position = mysql_prep($_POST['position']);
$visible = mysql_prep($_POST['visible']);

$query = "UPDATE 'widget_corp' . 'subjects' SET
    menu_name = '{$menu_name}',
    position = {$position},
    visible = {$visible}
    WHERE id = $id";
halfer
  • 19,824
  • 17
  • 99
  • 186
  • running that query would be a start `mysql_query($query);` and switch to a mysqli or pdo tutorial – Waygood May 01 '13 at 14:13
  • Have you execute this query by the function `mysql_query();` –  May 01 '13 at 14:14
  • I see this type of question all the time, you should read [common database debugging for PHP and MySQL](http://jason.pureconcepts.net/2013/04/common-debugging-php-mysql/). – Jason McCreary May 01 '13 at 14:50

1 Answers1

1

The error is on this line,

UPDATE 'widget_corp' . 'subjects' SET

identifiers (this includes column names and table names) shouldn't be wrapped with single quotes. If happens that an identifier is a reserve keyword, it can be escape with backticks, not with single quotes.

In this case remove the single quotes and it will work.

Additional Links that will help you give more details,

Community
  • 1
  • 1
John Woo
  • 258,903
  • 69
  • 498
  • 492
  • Thanks for the input but now i'm thinking the query is not the problem but somewhere before, cuz it's still working – user2339629 May 02 '13 at 11:53