Re: for loop problem?

From: Date: Tue, 13 Nov 2001 03:41:19 +0000
Subject: Re: for loop problem?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-74357@lists.php.net to get a copy of this message
My word why all the quotes? <? $connection = mysql_connect("blah","blah","blah"); $db = mysql_select_db("db_to_use", $connection); $value1 = 1000000; $value2 = 1223109; for($i=$value1; $i<=$value2; $i++) { mysql_query("INSERT INTO passcodes (passcode) VALUES ('P$i')"); if (mysql_error() != "") { print "<font face=Arial size=2>".mysql_error()."</font>"; exit; } } mysql_close($connection); ?> That should give you some better results. On Monday 12 November 2001 07:32 pm, you wrote: > Hello everyone, > > I have a pretty big list of codes that need to be put into a mysql db. The > numbers range from 1000000 to 1223109. Here's the PHP I wrote to put these > codes into a database: > > <? > $connection = mysql_connect("blah","blah","blah"); > $db = mysql_select_db("db_to_use", $connection); > $value1 = "1000000"; > $value2 = "1223109"; > for($i="$value1"; $i<="$value2"; $i++) { > mysql_query("INSERT INTO passcodes (passcode) VALUES ('P$i')"); > if (mysql_error() != "") { > print "<font face=Arial size=2>".mysql_error()."</font>"; > exit; > } > } > mysql_close($connection); > ?> > > Everytime I run this from a browser, it just keeps looping. It should put > about 223109 entries into the "passcodes" table. However, it just keeps > looping. I'll end up with 400,000 or so entries before I stop it. I make > sure I empty that table before I start running it again. Why is this > happening? > > Thanks everyone, > Tyler

« previous php.general (#74357) next »