php error occured by not confirm what error is behind -


i wrote php script , working fine getting error in not sure causing error in script because defined custom message in function this:

$error_display = "<div class='errormsgbox'>an error occured. please try again</div>"; 

is there way error getting little detail u can fix possible

here script

<?php // check empty errors  $sucess = null; $error_display = null; $slug_title = null;  if (isset($_post['formsubmitted'])) { $error = array();  //check video title     if (empty($_post['video_title'])) {         $error[] = 'you must enter video title';     } else {         $vid_title = $_post['video_title'];         //create slug using name         function create_slug($string){             $string = preg_replace( '/[^a-za-z0-9\. ]/', '', $string );                 $string = strtolower($string);                 $slug=preg_replace('/[^a-za-z0-9-]+/', '-', $string);             return $slug;             }             $slug_title = create_slug($vid_title);     }   //check ref id start // length want unique reference number       $unique_ref_length = 6;        // true/false variable lets know if we've       // found unique reference number or not       $unique_ref_found = false;        // define possible characters.       // notice how characters may confused such       // letter 'o' , number 0 don't exist       $possible_chars = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz234567890";        // until find unique reference, keep generating new ones       while (!$unique_ref_found) {            // start blank reference number           $unique_ref = "";            // set counter keep track of how many characters have            // been added           $i = 0;            // add random characters $possible_chars $unique_ref            // until $unique_ref_length reached           while ($i < $unique_ref_length) {                // pick random character $possible_chars list               $char = substr($possible_chars, mt_rand(0, strlen($possible_chars)-1), 1);                $unique_ref .= $char;                $i++;            }            // our new unique reference number generated.           // lets check if exists or not           $query = "select `vid_code` `tblmevids` `vid_code`='".$unique_ref."'";           $result = mysqli_query($conn, $query);           if (mysqli_num_rows($result)==0) {                // we've found unique number. lets set $unique_ref_found               // variable true , exit while loop               $unique_ref_found = true;            }        }   //check ref id end    //check channel selection     if ($_post['video_channel'] == 0) {         $error[] = 'you must select channel';     } else {         $channel_selectid = $_post['video_channel'];     }      $activation_vid = $_post['active_status'];     $featured_vid = $_post['featured_status'];     $metadescription = $_post['video_meta_descp'];     $submit_by = $_session['username'];     $metakeywords = $_post['video_meta_kywrd'];     $get_new_date = date('y-m-d g:i:s');     $set_new_vide_code = date("d").$unique_ref;     $slug_final = $set_new_vide_code."-".$slug_title;  //check dailymotion code     if (empty($_post['video_dm_code'])) {         $error[] = 'dailymotion video is must';     } else {         $dm_vid_code = $_post['video_dm_code'];             //grab dailymotion video duration             $duration_total='https://api.dailymotion.com/video/'.$dm_vid_code.'?fields=duration_formatted,thumbnail_360_url';             $json_duration = file_get_contents($duration_total);                     $get_duration = json_decode($json_duration, true);             $dm_duration_final = $get_duration['duration_formatted'];             $dm_make_thumbnail = $get_duration['thumbnail_360_url'];             $main_image = imagecreatefromstring(file_get_contents($dm_make_thumbnail));             // load logo image             $logoimage = imagecreatefromstring(file_get_contents($site_water_mark_path));             imagealphablending($logoimage, true);             // dimensions             $imagewidth=imagesx($main_image);             $imageheight=imagesy($main_image);             $logowidth=imagesx($logoimage);             $logoheight=imagesy($logoimage);              // paste logo             imagecopy(                // source             $main_image,                // destination             $logoimage,                // destination x , y             $imagewidth-$logowidth, $imageheight-$logoheight,                // source x , y             0, 0,                // width , height of area of source copy             $logowidth, $logoheight);                 ////////////////////////             imagejpeg($main_image, '../video_thumbs/'.$set_new_vide_code.'.jpg');      }   //check youtube code     if (empty($_post['video_yt_code'])) {         $yt_vid_code = null;     } else {         $yt_vid_code = $dm_duration_final;     }  // insert values database function start if (empty($error)) {     $sql = "insert `tblmevids` (vid_code, vid_title, vid_slug, vid_cat_id, vid_addedby_id, dm_vid_code, yt_vid_code, vid_act_stat, vid_featured_stat, vid_dm_duration, vid_yt_duration, vid_seo_descp, vid_seo_kywrd, vid_add_date)values ('$set_new_vide_code', '$vid_title', '$slug_final', '$channel_selectid', '$submit_by', '$dm_vid_code', '$yt_vid_code', '$activation_vid', '$featured_vid', '$dm_duration_final', '$yt_duration_final', '$metadescription', '$metakeywords', '$get_new_date')";         $result=mysqli_query($conn,$sql);         if($result){                 // insert social data start                 $fb_status = intval(0);                 $twt_status = intval(0);                 $sql_share = "insert `tblsocial_share` (vidsc_code, vid_fb_sstat, vid_twt_sstat)values ('$set_new_vide_code', '$fb_status', '$twt_status')";                 $result_social=mysqli_query($conn,$sql_share);                     if($result_social) {                 $sucess = "<div class='success'>perfect!!! new video has been added</div>";                     } else {                 $error_display = "<div class='errormsgbox'>1 error occured. please try again</div>";                     }                 // insert social data end         } else {                 $error_display = "<div class='errormsgbox'>2 error occured. please try again</div>";         }  } else { //erros display '         $error_show =  '';         foreach ($error $key => $values) {             $error_show .=' <li>'. $values.'</li>';              $error_display = "<div class='errormsgbox'> <ol>".$error_show."</ol></div>";               } } // insert values database function end } ?> 

where $conn (connection variable) set? have no result form query, maybe problem.

if insert query generate error, check it:

mysqli_query($conn,$sql) or die(mysqli_error($conn)); 

Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -