The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

What you have there is a result resource, just like running any other query. You will get exactly the same result if you replaced the SQL with any other query. You need to get an associate array / numeric-indexed array out of the result resource before you can use the value returned from the query.

Alternatively, what is wrong with using the php mysql_insert_id() or mysqli->insert_id functions/properties, to avoid having to query the database again?

Try echoing out the query before inserting it, and run it manually in phpMyAdmin, see what you get. I don't like those curly braces everywhere personally, I always break out of the string to put variables into it.

Finally, you are running the query inside the foreach loop, which is fairly obviously wrong. The query is going to be run for each of the post variables, and for the first 3, not all the values are going to be set. You want to run the query after the foreach loop, not within it.

Finally, you are running the query inside the foreach loop, which is fairly obviously wrong. The query is going to be run for each of the post variables, and for the first 3, not all the values are going to be set. You want to run the query after the foreach loop, not within it.

After many trying to debug as well as try out other values, the setcookie(listing_id, $lisingting_id....) now works without causing trouble .I think I luckily accidentally deleted the error code during the process.