Re: 2D array into mySQL DB

From: Date: Sat, 12 Jan 2002 04:43:04 +0000
Subject: Re: 2D array into mySQL DB
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-15688@lists.php.net to get a copy of this message
On Saturday 12 January 2002 10:42, Adam Royle wrote: > 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); > } You don't say what error, if any, you're getting. My best guess is that you probably need to use addslashes() to treat your data before inserting into the database. hth -- Jason Wong -> Gremlins Associates -> www.gremlins.com.hk /* "I'd love to go out with you, but I did my own thing and now I've got to undo it." */

« previous php.db (#15688) next »