Jump to content

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


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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.