php - Wp not insert blank value -


i have used if isset when image not upload insert blank value, if not upload image sql not inserted. want when image doesn't upload, insert blank value $aencode1 = '';

thanks!

global $wpdb;    $county         = $_post["county"]; //--------* image 1 *----------////////////  if(isset($_files["image_1"]["tmp_name"]) && !empty($_files["image_1"]["tmp_name"])) {     $file_handler1  = 'image_1'; //form attachment field name.     $image_1        = media_handle_upload( $file_handler1, $post_id1 );     $aencode1 = $image_1;     echo '1  isset'; }else{     $aencode1   = ''; } //--------* image 2 *----------//////////// if(isset($_files["image_2"]["tmp_name"]) && !empty($_files["image_2"]["tmp_name"])) {     $file_handler2  = 'image_2'; //form attachment field name.     $image_2        = media_handle_upload( $file_handler2, $post_id2 );     $aencode2       = $image_2; }else{     $aencode2 = ''; }  var_dump($aencode2);  $sql = $wpdb->insert(     'hotels', //table     array(     'county'        => $county,     'image_1'       => $aencode1,     'image_2'       => $aencode2)    //array('%s', '%s') //data format ); 


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -