Re: Empty Query

From: Date: Tue, 25 Feb 2003 21:13:25 +0000
Subject: Re: Empty Query
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-137138@lists.php.net to get a copy of this message
From what I can tell, if $img is an empty string, and $file_dir is not a directory, $sql will not be assigned a value. This could be what's causing your error when you try to run an empty query. ---John Holmes... ----- Original Message ----- From: "Richard Whitney" <rw@xend.net> To: <php-general@lists.php.net> Sent: Tuesday, February 25, 2003 3:25 PM Subject: [PHP] Empty Query > ### I have this: > ### > ### 1111[serial] > ### 1111[model] > ### 1111[yr_blt] > ### 1111[km] > ### 1111[price] > ### 1111[hours] > ### 1111[details] > ### 1111[location] > ### double[style] > > All of the 1 are the variables being passed, the word is hardcoded for clarity > > > What I get half the time: Couldn't insert dataQuery was empty > ### > ### The variables are obviously being passed > ### > ### Here's my insert query: > ### > ### if($img == ""){ $sql = "INSERT INTO vehicles ( > id ,serial, model , > ### yr_blt , km , > price , hours , > details , location , > img, > ### tstamp, > ### style) > ### VALUES ('', '$serial', > '$model', '$yr_blt', '$km', '$price', > ### '$hours', > ### '$details', '$location', '0', '$tstamp', > '$style');"; > ### } > ### else > ### { > ### > ### > $file_dir="/services/webpages/o/f/offroad-imports.com/public/uploads/mogs/$s erial"; > ### if (!is_dir($file_dir)){ > ### umask(000); > ### mkdir($file_dir,0777); > ### } > ### else{ > ### umask(000); > ### > ### $path = $file_dir . "/1.jpg"; > ### move_uploaded_file($img, $path)or die('Could not upload photo'); > ### $sql = "INSERT INTO vehicles ( id > ,serial, model , yr_blt , > km > ### , > ### price , hours , > details , location , > img, tstamp, > style) > ### VALUES ('', '$serial', > '$model', '$yr_blt', '$km', '$price', > ### '$hours', > ### '$details', '$location', '1', '$tstamp', > '$style');"; > ### } > ### > ### } > > Any thoughts? Enlightenment? > > Thanks > > -- > Richard Whitney * > Transcend Development > Producing the next phase of your internet presence. > rw@xend.net * > http://xend.net * > 602-971-2791 > * * * > * * *__ * * > _/ \___ * > * / * \* * > */ * * \ > * */\_ |\ > / \_ / \ > / \____/ \ > / \ > / \ > / \ > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.general (#137138) next »