Re: working with CSV data: getting "Query was empty"

From: Date: Tue, 22 Oct 2002 14:46:50 +0000
Subject: Re: working with CSV data: getting "Query was empty"
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-120918@lists.php.net to get a copy of this message
What is updatequery() method? Where is it's source? --- Maxim Maletsky maxim@php.net www.PHPBeginner.com // PHP for Beginners www.maxim.cx // my Home // my Wish List: ( Get me something! ) http://www.amazon.com/exec/obidos/registry/2IXE7SMI5EDI3 "Rick Emery" <remery@emeryloftus.com> wrote... : > Correct me if I'm wrong, but I don't see where you passed $sql to updatequery() > > ----- Original Message ----- > From: "Kevin Porter" <Kevin.Porter@becta.org.uk> > To: <php-general@lists.php.net> > Sent: Tuesday, October 22, 2002 6:48 AM > Subject: [PHP] working with CSV data: getting "Query was empty" > > > Hi, > > I'm importing data from a CSV file using PHP's fgetscv() function. For each > line read from the CSV file, I am using it so update fields in the DB. The > SQL query I generate works fine from the command line, but in the browser I > just get "Query not empty". > > A quick google told me people have seen these problems when using fgetcsv() > with CSV files generated on Windows, but I've already remove any sneaky ~V > characters etc manually, as well as running the file through dos2unix, but I > _still_ get the same error. I'd be grateful to anyone who can shed any light > on this. > > Here's the code, the first few lines form my CSV file and the output... > > The Code: > > $csvfile = 'summaries.csv'; > > $type_name_map = array( 'whatis' => 'WhatIs', 'howto' => > 'HowTo' ); > > // Get fields TypeId, Type and Summary (comma-delimited) > > $db = new Database('mysqldb'); > ($fp=fopen($csvfile,'r')) or die( "Couldn't open CSV file" ); > > while ( $data = fgetcsv($fp, 10000, ',') ) > { > for ( $i=0, $i2=count($data); $i < $i2; $i++ ) > { > $sql = "update ".$type_name_map[$data[1]]." set Summary = > '".$data[2]."' where id = ".$data[0]; > echo "\$sql = **$sql**<br>"; > > $db->updatequery(); > > } > } > > > > > CSV data: > > > 5,howto,"Replying, saving, printing and deleting e-mail messages - and what > to do if one bounces back." > 9,howto,"E-mail management hints and tips, and how to send large files and > attachments." > 11,howto,Joining an on-line community such as a mailing list or Usenet group > to share ideas. > > > The output generated: > > $sql = **update HowTo set Summary = 'Replying, saving, printing and deleting > e-mail messages - and what to do if one bounces back.' where id = 5** > Query was empty > > > As I said earlier, if I cut and paste $sql into MySQL command line the query > works fine. > > Help! > > regards, > > > - Kev > > > > > > > ********************************************************************** > This email and any files transmitted with it are confidential and > intended solely for the use of the individual or entity to whom they > are addressed. If you have received this email in error please notify > the system manager. > This footnote also confirms that this email message has been swept by > MIMEsweeper for the presence of computer viruses. > www.mimesweeper.com > ********************************************************************** > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >

« previous php.general (#120918) next »