socalnate Posted November 1, 2007 Share Posted November 1, 2007 You know how MYSQL automatically generates an incremental id using auto_increment? My goal is to copy the id that was just generated from a PHP SQL insert in table 1, to table 2, and table 3. AKA I'm copying the ID value to different tables generated from one. The reason being is that there aren't the same number of rows in table 2 or table 3 so my ID value will be off. However, for some reason my table 2 and table 3 aren't getting the $id value...Anybody know what I'm doing wrong? ??? $id_query = mysql_query("SELECT title_name FROM eg_titles WHERE title_name = '$title_name'", $login); if (!$id_query) { echo("<p>Error performing query: " . mysql_error() . "</p>"); exit(); } $row = mysql_fetch_row($id_query); [color=red]$id [/color]= $row[0]; $description_insert = mysql_query("INSERT INTO eg_descriptions(`id`, `cr_datetime`, `title_name`, `description`) VALUES ('[color=red]$id[/color]', NOW(), '$title_name', '$description')") or die (mysql_error() . " - AT 777 description_insert query."); FYI, I'm using LEFT JOINS Quote Link to comment https://forums.phpfreaks.com/topic/75674-solved-mysql-copying-an-audio-increment-id-across-multiple-tables/ Share on other sites More sharing options...
Barand Posted November 1, 2007 Share Posted November 1, 2007 Your first query doesn't select an id so title_name is in $row[0] Quote Link to comment https://forums.phpfreaks.com/topic/75674-solved-mysql-copying-an-audio-increment-id-across-multiple-tables/#findComment-382945 Share on other sites More sharing options...
socalnate Posted November 1, 2007 Author Share Posted November 1, 2007 Thanks you are very correct! Quote Link to comment https://forums.phpfreaks.com/topic/75674-solved-mysql-copying-an-audio-increment-id-across-multiple-tables/#findComment-383093 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.