Page 1 of 1

Modify SQL table with php

Posted: Sun Aug 22, 2004 3:45 am
by Jim
[code]$id = $_GET[\'id\'];

mysql_connect("localhost","{{username}}","{{password}}");
mysql_select_db("{{database}}");

$tablename = $_POST[\'category\'];
$title = $_POST[\'title\'];
$definition = $_POST[\'definition\'];
mysql_query(UPDATE $tablename SET title = $title, definition = $definition WHERE auto_id = $id LIMIT 1);[/code]

I have this code, but i get an error on the last line.
[code]Parse error: parse error, unexpected T_VARIABLE[/code]

anyone have any suggestions to fix this?

Modify SQL table with php

Posted: Sun Aug 22, 2004 4:11 am
by Josh
What line is it telling you the error is on? We can\'t do much if we don\'t have the line number /blum.gif\' class=\'bbc_emoticon\' alt=\':P\' />

Anyway, I went to zend just to check it quickly and it had nothing but errors through the whole thing and I added quotes in the mysql_query. That seemed to fix everything.

[code]$id = $_GET[\'id\'];

mysql_connect("localhost","{{username}}","{{password}}");
mysql_select_db("{{database}}");

$tablename = $_POST[\'category\'];
$title = $_POST[\'title\'];
$definition = $_POST[\'definition\'];
mysql_query("UPDATE $tablename SET title = $title, definition = $definition WHERE auto_id = $id LIMIT 1");[/code]