RE: [PHP] What's wrong with this script ??

From: Date: Sun, 23 Jul 2000 02:10:25 +0000
Subject: RE: [PHP] What's wrong with this script ??
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-7745@lists.php.net to get a copy of this message
Did you sort this out? What is mysql_exec? Is that an undocumented function? I thought it was mysql_query($query); You don't need the final semi-colon when submitting queries from PHP.... Also, what happens if some of your array values are empty? mysql probably wont like the following... INSERT INTO news (title,description, date) VALUES (, 24, 23); HTH Matthew Clark. >-----Original Message----- >From: Vadee Prudon [mailto:v.prudon@davidson.nl] >Sent: 20 July 2000 01:38 PM >To: php-general@lists.php.net >Subject: [PHP] What's wrong with this script ?? > > >Hai, > >I've got an problem, I want to upload an csv file and import automatic the >data into my mysql database. >I made the next script but got an error on line 25 (that's my query). >Can someone help me ? Or is there an better way to get data out of >Filemaker >Pro into MySQL ? > ><? >include "include/mysql_support.inc.php3"; >include "include/layout.inc.php3"; >commonHeader(); >?> > ><? >$row = 1; >$fp = fopen ("test.csv","r"); >while ($data = fgetcsv ($fp, 1000, ",")) > >{ >$num = count ($data); >print "<p> $num fields in line $row: <BR>"; > $row++; >for ($c=0; $c<$num; $c++) >{ > print $data[$c]. "<BR>"; > } >} >fclose ($fp); >?> > ><? >$Query = "INSERT INTO news (title,description, date) VALUES >($data[0],$data[1], $data[3])"; >mysql_exec($Query); >?> > > > > >-- >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 (#7745) next »