The $music_artist.id is the id from the first page. ( database = music , table = music_artist id ). This is what I need, a drop down list of the artists in table 'music_artist'( I've got this), I want the id of the artist they selected in the drop list to be inserted into the table 'music_album' as $artist_id.
-----Original Message----- From: Gurhan Ozen <[EMAIL PROTECTED]> To: Barry Rumsey <[EMAIL PROTECTED]>, php-db list <php- [EMAIL PROTECTED]> Date: Wed, 17 Apr 2002 19:02:52 -0400 Subject: RE: [PHP-DB] drop list inserts > Hi Barry, > First of all, > $query_id = mysql_query("INSERT INTO...); is wrong. That line will > just > assign the resultset of the whatever mysql_query() function returns to > the > variable $query_id .. Get rid of $query_id and just have > mysql_query(INSERt > INTO ....); See: http://www.php.net/manual/en/function.mysql-query.php > for > this.. > Second of all, in your INSERT INTO query you are trying to insert the > value > of a variable called $music_artist.id which doesn't exist anywhere. I > think > you meant to insert $artist_name instead??? > > Gurhan > > > -----Original Message----- > From: Barry Rumsey [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, April 17, 2002 6:23 PM > To: php-db list > Subject: [PHP-DB] drop list inserts > > > I have the following to pages( just testing them at the moment ): > <? mysql_connect("host","xxxx","xxxx"); > mysql_select_db("music"); > echo "<form name='add_album' method='post' > action='test-album-add.php'>"; > $getlist = mysql_query("SELECT * FROM music_artist ORDER BY > artist_name ASC"); > echo " Artist Name : <select name=\"artist_name\">\n"; > while ($row = mysql_fetch_array($getlist)) { > echo '<option > value="'.$row["id"].'">'.$row["artist_name"]."</option>\n"; > } > echo " </select>\n"; > echo "<br>Album Name : <input type='text' name='album' > value='$album'>"; > echo "<input type='submit' name='Submit' value='Submit'>"; > echo "</form>"; > ?> > > and > > <? > include("../mainfile.php"); > include("../header.php"); > OpenTable(); > > mysql_connect( "host", "xxxx", "xxxx" ); > mysql_select_db( "xoops" ); > > $query_id = mysql_query("INSERT INTO music_album VALUES > (NULL, '$music_artist.id' ,'$album' ,NULL ,NULL)"); > echo " $artist_name and $album has been added to the > database."; > CloseTable(); > include("../footer.php"); > ?> > > What I am trying to do is insert the id of the artist they selected in > the first page into a second table. At the moment all I get is 0 > inserted instead of the artist id from page 1. > > Could someone please point out what I'm doing wrong? > > Thanks in advance. > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php