Hello jack,

Friday, June 10, 2005, 3:11:17 AM, you wrote:

jj> All the first part of the query works and inserts records into the
jj> database, and it's when I try to get mysql_insert_id () that I seem to
jj> run into trouble. Ah. ave I not yet run the first query? The part of
jj> the code that actually runs it was given to me in a class and I don't
jj> quite understand how it's suppose to be working ...

You didn't appear to be running the query before trying to get the
last ID - so there's obviously not going to be an ID which will cause
the subsequent queries to fail, as they rely on them.

jj>             foreach ($media_types[] as $type)
jj>                 {

jj>                   $query .= "INSERT INTO media_art
jj> (media_art_id,media_id, art_id)
jj>                    VALUES ('','" . $type . "','" . $art_id . "')";
jj>                    // perform query here

Before you run the query you need to check what $type contains - you
don't want to perform an insert for every single checkbox, only for
those that have actually been checked.

Also - you don't appear to be actually performing the query at all
here - you're just appending it onto the $query string. You can't do
it like this if you need the IDs returned - you have to actually DO
the query THEN get the ID, then move onto the next stage.

So at this point in your code you need to actually perform a query.

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to