How can I have, for example, multiple INSERT statements in a string and pass that string to
mysql_query?
$sql .= "INSERT INTO table (column1, column2) VALUES ('apple', 'orange')";
$sql .= "INSERT INTO table (column1, column2) VALUES ('red', 'blue')";
mysql_query($sql, $conn);
This is basically what I have but I'm geting an error.
I've also tried:
$sql .= "INSERT INTO table (column1, column2) VALUES ('apple', 'orange');";
SQL query string
Moderator: General Moderators
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
mysql_query() doesn't support multiple statements.. however you may be able to perform:which would, provided your install supports it, create 2 records.
Code: Select all
INSERT INTO table (a,b,c) VALUES (1,2,3),(4,5,6)