Mr Chris Posted June 5, 2007 Share Posted June 5, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/54244-insert-into-problem/ Share on other sites More sharing options...
mmarif4u Posted June 5, 2007 Share Posted June 5, 2007 try to put this in ur query: $sql[0] and $sql[1] Quote Link to comment https://forums.phpfreaks.com/topic/54244-insert-into-problem/#findComment-268221 Share on other sites More sharing options...
Mr Chris Posted June 5, 2007 Author Share Posted June 5, 2007 Sorry, but where abouts? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/54244-insert-into-problem/#findComment-268232 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.