Modify SQL table with php

Support, Snippets & Projects

Moderators: Moderator, Global Moderator

Post Reply
Jim
Administrator
Administrator
Posts: 1324
Joined: Wed Jun 16, 2004 5:37 pm

Modify SQL table with php

Post 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?
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 7:54 am

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: 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");
Last edited by Josh on Sat Aug 21, 2004 9:14 pm, 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”