Please help with UPDATING DATABASE from php form.
Posted: Tue Jan 28, 2003 1:55 am
I am trying to update information i have stored in a database table that i have already created. I keep getting a sql error of:
You have an error in your SQL syntax near '' at line 1
SELECT id FROM resources WHERE id =
My code for the php script to do the actual update is the following:
<?php
$sql = "SELECT id FROM resources WHERE id = $id";
@mysql_select_db(webtemp_123webtemplates) or die(mysql_error());
@$result = mysql_query($sql) or die(mysql_error().'<p>'.$sql.'</p>');
if (mysql_num_rows($result) < 1) {
echo 'Required information has been deleted.';
} else {
$sql = "UPDATE resources";
$sql .= "SET link_name = '".addslashes(trim($link_name))."'";
$sql .= "SET link_url = '".addslashes(trim($link_url))."'";
$sql .= "SET link_rating = '".addslashes(trim($link_rating))."'";
$sql .= "SET link_desc = '".addslashes(trim($link_desc))."'";
$sql .= "WHERE id = $id";
@mysql_query($sql) or die(mysql_error().'<p>'.$sql.'</p>');
}
?>
Any help is always greatly appreciated from the members of this forum,
Matt Urban
a.k.a -=urb=-
You have an error in your SQL syntax near '' at line 1
SELECT id FROM resources WHERE id =
My code for the php script to do the actual update is the following:
<?php
$sql = "SELECT id FROM resources WHERE id = $id";
@mysql_select_db(webtemp_123webtemplates) or die(mysql_error());
@$result = mysql_query($sql) or die(mysql_error().'<p>'.$sql.'</p>');
if (mysql_num_rows($result) < 1) {
echo 'Required information has been deleted.';
} else {
$sql = "UPDATE resources";
$sql .= "SET link_name = '".addslashes(trim($link_name))."'";
$sql .= "SET link_url = '".addslashes(trim($link_url))."'";
$sql .= "SET link_rating = '".addslashes(trim($link_rating))."'";
$sql .= "SET link_desc = '".addslashes(trim($link_desc))."'";
$sql .= "WHERE id = $id";
@mysql_query($sql) or die(mysql_error().'<p>'.$sql.'</p>');
}
?>
Any help is always greatly appreciated from the members of this forum,
Matt Urban
a.k.a -=urb=-