Jump to content

Insert into problem?


Mr Chris

Recommended Posts

Hi Guys,

 

I’m trying to create an array to post multiple values into my database table.

 


$lastinsert = mysql_insert_id(); //to get report_id from reports table

$sql = array(); 
foreach($_REQUEST['r'] as $row)
   { 
        $sql[] = sprintf("('%s', %d)", 
            $player_id = $row['player_id'],
            $team_id = $_GET['team_id']);    
    } 

$query_three = mysql_query("INSERT INTO `goals2` ( `player_id`,`team_id`, `report_id` ) 
VALUES ('$sql', '$lastinsert')");

 

Now I want to get the first two values from the array I created and the $lastinsert value (report_id) from the last insert in another table.  However it just outputs the message ‘query is empty’ in my validation checks to see if any data enters the database.

 

Anyone see what’s wrong please?

 

Thanks

 

Chris

 

Link to comment
https://forums.phpfreaks.com/topic/54244-insert-into-problem/
Share on other sites

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.