Jump to content

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

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.