View Single Post
Old 06-04-2004, 08:43 AM   #1 (permalink)
metazai
Regular Contributor
 
Join Date: Apr 2004
Location: Orange County, CA
Posts: 125
metazai is on a distinguished road
Unhappy Can't do a simple flippin' update . . .

Every time I pat myself on the back for having learned something, I screw up something simple like this . . . . yarrgh!

Ok, I've got a page where basic entries (title and entry) in an existing SQL table can be changed. The following code displays the correct entries via a post from the previous page (entryid), but the submit button invariable produces:

"You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1"

PHP Code:
<?php
$lnk 
mysql_connect('mysqladdress''login''password') or die (mysql_error());
mysql_select_db('tablename',$lnk);
$query_title "SELECT title FROM tablename WHERE id = ".$entryid;
$pre_title mysql_query($query_title$lnk) or die(mysql_error());
$row_title mysql_result($pre_title,0,0);
$title stripslashes($row_title);
$query_entry "SELECT entry FROM tablename WHERE id = ".$entryid;
$pre_entry mysql_query($query_entry$lnk) or die(mysql_error());
$row_entry mysql_result($pre_entry,0,0);
$entry stripslashes($row_entry); ?>

<form method="post" action="<?=$PHP_SELF?>">
<?php echo($entryid); ?>
<input type="text" name="newtitle" value="<?php echo($title); ?>">
<br />
<textarea name="newentry" rows="10" cols="70">
<?php echo($entry); ?>
</textarea>
<br />
<input type="Submit" name="submitentry" value="submit">
</form>
<?php if ($submitentry == "submit") { 
$updquery "UPDATE may2004 SET title=\'".$newtitle."\',entry=\'".$newentry."\' WHERE id=\'".$entryid."\'";
mysql_query($updquery,$lnk) or die(mysql_error()); 
echo(
"<p>Your entry has been updated.</p>"); 
}
    
?>
I know it's something simple, but I just can't see it.
metazai is offline   Reply With Quote