2D array into mySQL DB

From: Date: Sat, 12 Jan 2002 02:42:48 +0000
Subject: 2D array into mySQL DB
Groups: php.db 
Request: Send a blank email to php-db+get-15684@lists.php.net to get a copy of this message
Hi there... I wrote a PHP script which extracts the title and content from all the HTML files in a directory and puts the filename, title and content into a 2 dimensional array. I know the array is fine because when I print it to the page it dislays properly. When I try to input it into the DB I think mySQL chokes. Is there a better way to put contents of an array in a db, or some way to slow down the process? I have tried using insert delayed, and also doing a complex calculation after each insert to keep the php engine thiking but allowing mysql to fix itself, but this does not work. The results I get in the db is muffled and only contains three rows (instead of about 15) and the information is all jumbled aswell. I tried a test line (commented out) and it worked as expected. This is my code. for ($i=0;$i<count($arr_page);$i++){ $sql = "INSERT into tblContent (Title, Filename, Parent, DirName, Content) VALUES ('$arr_page[$i][0]','$arr_page[$i][1]','$parent','$dir_name','$arr_page[$i] [2]')"; //('$i','$i','$i','$i','$i')"; this line instead of previous inserts as expected mysql_query($sql); } Any help would be appreciated. Adam

« previous php.db (#15684) next »