>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" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> 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. > [EMAIL PROTECTED] * > http://xend.net * > 602-971-2791 > * * * > * * *__ * * > _/ \___ * > * / * \* * > */ * * \ > * */\_ |\ > / \_ / \ > / \____/ \ > / \ > / \ > / \ > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php