Modify SQL table with php

Support, Snippets & Projects

Moderators: Moderator, Global Moderator

Post Reply
Jim
Administrator
Administrator
Posts: 1324
Joined: Thu Jun 17, 2004 12:37 am

Modify SQL table with php

Post 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?
Love is all a matter of timing.

It's no good meeting the right person too soon or too late.

If I'd live in another time or place...

...my story might have had a very different ending.
Josh
Hero Member
Hero Member
Posts: 4627
Joined: Fri Jun 04, 2004 2:54 pm

Modify SQL table with php

Post 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]
Last edited by Josh on Sun Aug 22, 2004 4:14 am, edited 1 time in total.
[align=center]

Image

“If you stop learning, you stop living.” ~Tami Quiring

“It's the rare man who understands the value of a single perfect rose.”

[/align]
Post Reply

Return to “PHP & MySQL”