Re: UPDATE

From: Date: Mon, 20 Dec 2004 14:57:28 +0000
Subject: Re: UPDATE
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-204697@lists.php.net to get a copy of this message
Steve Marquez wrote:
I am trying to insert information into the database, have it automatically place an ID Number, then update that particular record and replace the word "delete" with the link. The "mysql_insert_id()" does seem to be working. It does put in an id number of "0" However, the code in general gives me an error everytime. It says that it is near 'delete = <a href...' Can anyone help me with this? Thanks! -- Steve
<?php    
// log into our local server using the MySQL root user. $dbh = mysql_connect( "localhost", "username", "password" ); // select the database. mysql_select_db( "imagesdb" ) or die ( mysql_error() . "\n" ); ?> <-- snip --> <?php //This is for the text description of the gallery and the link $insert_data2 = "INSERT into images_upload_description (delete, name, description) VALUES ('delete', '<a href=\"http://www.domain.org/gallery/bomb/bottom_images.php?gallery_name=$ga llery_name\" target=\"bottom\">$name</a>', '$description');"; $response = mysql_query( $insert_data2, $dbh ); $id_num = mysql_insert_id(); $update_data = "UPDATE images_upload_description SET delete = <a href=\"http://www.domain.org/gallery/admin/delete.php?gallery_name=$gallery_ name&id_num=$id_num\" target=\"bottom\">Delete</a> WHERE id_num = \"$id_num\"";
              $response = mysql_query( $update_data, $dbh );
if(mysql_error()) die ('database error'. mysql_error()); ?> You forgot to put single quotes around the string that begins '<a href= ... ' in the line beginning:
$update_data = "UPDATE images_upload_description SET delete = <a href=\"http://www.domain.org/gallery/admin/delete.php?gallery_name=$gallery_name&id_num=$id_num\" target=\"bottom\">Delete</a> WHERE id_num = \"$id_num\""; -John

« previous php.general (#204697) next »