Re: new to php/mysql - insert not working

From: Date: Wed, 20 Mar 2002 17:22:30 +0000
Subject: Re: new to php/mysql - insert not working
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-89352@lists.php.net to get a copy of this message
Robert, I still feel fairly new to this myself but if I find that I'm having problems writing to the database I generally try to echo the query to the page and then test this out directly with the command line prompt directly to the database. At least that way you can test out the query in isolation. Good luck, Michael > The following code gets me "document contains no data." I have done a > successfull select from mysql db, but not an insertion. > > I don't know how to troubleshoot this. Any help is much appreciated. > Thanks! > > <?php > > $id = addslashes($id); > $visitdate = addslashes($visitdate); > $img_group = addslashes($img_group); > $img_url = addslashes($img_url); > $display = addslashes($display); > > @ $db = mysql_connect("www", "mmc", "mmc-WWW"); > > if (!$db) > { > echo "Error: Could not connect to database. Please try again > later."; > exit; > } > > mysql_select_db("mmc"); > $query = "insert into visitorgallery values > ('".$id."', '".$img_url."', > '".$visitdate."', > '".$img_group."', '".$display."', )"; > > > $result = mysql_query($query); > if ($result) > echo mysql_affected_rows()." Image inserted! "; > > ?> > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#89352) next »