Page 1 of 1

Modify SQL table with php

Posted: Sat Aug 21, 2004 8:45 pm
by Jim

Code: Select all

$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);
I have this code, but i get an error on the last line.

Code: Select all

Parse error: parse error, unexpected T_VARIABLE
anyone have any suggestions to fix this?

Modify SQL table with php

Posted: Sat Aug 21, 2004 9:11 pm
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: Select all

$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");