apw Posted July 24, 2008 Share Posted July 24, 2008 Hello, ive ran into a problem with sql insert. My register.php file contains playername, password, email, empirename and title along with those when player submits the info the player provided gets pas sed to another php file called reguser.php in this file the info the player provided is checked and inserted into a table called pfile. The insert into pfile works fine but when i tried placing a similar insert below the insert into pfile, after the ; at the end the information doesnt get inserted it doesnt generate an error and the pfile insert above the new insert also doesnt work. my question is how do i go about adding multiple inserts within that php file Quote Link to comment Share on other sites More sharing options...
apw Posted July 24, 2008 Author Share Posted July 24, 2008 Alas could the reason the second insert into isnt working because i do not have a line mysql_query($sql) similar to the line above that does have that following it? Quote Link to comment Share on other sites More sharing options...
.josh Posted July 24, 2008 Share Posted July 24, 2008 php does not support multiple queries like that. You need to run each query string individually. Quote Link to comment Share on other sites More sharing options...
Barand Posted July 24, 2008 Share Posted July 24, 2008 You can insert multiple records using this syntax (faster than multiple single inserts) INSERT INTO table (x, y, z) VALUES ($a, $b, $c), ($d, $e, $f), ($g, $h, $i), ($j, $k, $l) Quote Link to comment Share on other sites More sharing options...
dannyb785 Posted July 24, 2008 Share Posted July 24, 2008 You can insert multiple records using this syntax (faster than multiple single inserts) INSERT INTO table (x, y, z) VALUES ($a, $b, $c), ($d, $e, $f), ($g, $h, $i), ($j, $k, $l) whooooooooooooooooooooooooaaa!! are you serious?? thats awesome!! Quote Link to comment Share on other sites More sharing options...
.josh Posted July 24, 2008 Share Posted July 24, 2008 yeah i knew that. Good call Barand. I was too focused on the whole multiple queries separated by a ; to think about it. Quote Link to comment 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.