Jump to content

[SOLVED] MYSQL copying an audio-increment ID across multiple tables


socalnate

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.