Re: Multiple Inserts

From: Date: Fri, 09 Mar 2001 12:57:47 +0000
Subject: Re: Multiple Inserts
Groups: php.general 
Request: Send a blank email to php-general+get-43138@lists.php.net to get a copy of this message
The trick here is to do some debugging :) Firstly make sure that your error reporting level is set to E_ALL in php.ini - then you've got some chance of seeing error and warning messages. Secondly, while there are probably loads of ways of doing what you are trying to do, all the correct ones will check the return value from ALL the mysql calls. The mysql functions return 0 if something went wrong. There's absolutely no point carrying on to the next stage since when you pass the 0 into the next stage it will just complain (if your error reporting level is set high enough) - it simply can't do the next bit with a connection or result handle of 0. So, for each mysql call do something like: $Thingy = mysql_whatnot(blah) or die('it went wrong doing whatnot, mysql says '.mysql_error()); and if that doesn't give you the clue you need (which it will 99% of the time, echo out the SQL statement and see if that looks silly in any way. Good luck. -- Phil Driscoll Dial Solutions +44 (0)113 294 5112 http://www.dialsolutions.com http://www.dtonline.org -----Original Message----- From: Website4S@aol.com <Website4S@aol.com> To: php-general@lists.php.net <php-general@lists.php.net> Date: Friday, March 09, 2001 12:31 PM Subject: [PHP] Multiple Inserts >Hi, > >I am trying to do some multiple inserts using the following code but it >doesn`t seem to work, it inserts the first one but then the second is >inserted as blank. Where the value being passed is > >$Emails="test@test.com, test1@test.com"; > ><? >// Get Login info > >require("blah..."); > >// Connect to MySQL > >$connection=mysql_connect($host, $user, $pass); > >// Format the Emails > >$Emails1=str_replace(" ","",$Emails); >$GetEmails=explode(",",$Emails1); > >// Insert into Members Database > >for =0;$a<count($GetEmails);$a++){ >$SQLStatement = "INSERT INTO Members (Email) VALUES ('".$GetEmails[$a] >."')" >or die ("Problem"); >$db = mysql_select_db($dbase, $connection); >$SQLResult = mysql_query($SQLState ment); > >} > >?> > >Anyone know what might be going wrong, or perhaps I have the wrong method? > >Thanks >Ade > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net >For additional commands, e-mail: php-general-help@lists.php.net >To contact the list administrators, e-mail: php-list-admin@lists.php.net > >

« previous php.general (#43138) next »