php错误由未确认错误背后的内容而发生

php错误由未确认错误背后的内容而发生,php,Php,我编写了一个php脚本,它工作正常,但现在我发现其中有一个错误,但我不确定是什么导致了脚本中的错误,因为我在函数中定义了一条自定义消息,如下所示: $error_display = "<div class='errormsgbox'>An error occured. Please Try Again</div>"; 有没有办法通过一点细节来了解我所遇到的错误,这样你就可以解决它?有可能吗 这是我的剧本 <?php // check for empty error

我编写了一个php脚本,它工作正常,但现在我发现其中有一个错误,但我不确定是什么导致了脚本中的错误,因为我在函数中定义了一条自定义消息,如下所示:

$error_display = "<div class='errormsgbox'>An error occured. Please Try Again</div>";
有没有办法通过一点细节来了解我所遇到的错误,这样你就可以解决它?有可能吗

这是我的剧本

<?php
// check for 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 a 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
// The length we want the unique reference number to be  
    $unique_ref_length = 6;  

    // A true/false variable that lets us know if we've  
    // found a unique reference number or not  
    $unique_ref_found = false;  

    // Define possible characters.  
    // Notice how characters that may be confused such  
    // as the letter 'O' and the number zero don't exist  
    $possible_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ234567890";  

    // Until we find a unique reference, keep generating new ones  
    while (!$unique_ref_found) {  

        // Start with a blank reference number  
        $unique_ref = "";  

        // Set up a counter to keep track of how many characters have   
        // currently been added  
        $i = 0;  

        // Add random characters from $possible_chars to $unique_ref   
        // until $unique_ref_length is reached  
        while ($i < $unique_ref_length) {  

            // Pick a random character from the $possible_chars list  
            $char = substr($possible_chars, mt_rand(0, strlen($possible_chars)-1), 1);  

            $unique_ref .= $char;  

            $i++;  

        }  

        // Our new unique reference number is generated.  
        // Lets check if it exists or not  
        $query = "SELECT `vid_code` FROM `tblmevids` WHERE `vid_code`='".$unique_ref."'";  
        $result = mysqli_query($conn, $query);  
        if (mysqli_num_rows($result)==0) {  

            // We've found a unique number. Lets set the $unique_ref_found  
            // variable to true and exit the 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 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 the logo image
            $logoImage = imagecreatefromstring(file_get_contents($site_water_mark_path));
            imagealphablending($logoImage, true);
            // Get dimensions
            $imageWidth=imagesx($main_image);
            $imageHeight=imagesy($main_image);
            $logoWidth=imagesx($logoImage);
            $logoHeight=imagesy($logoImage); 
            // Paste the logo
            imagecopy(
               // source
            $main_image,
               // destination
            $logoImage,
               // destination x and y
            $imageWidth-$logoWidth, $imageHeight-$logoHeight,
               // source x and y
            0, 0,
               // width and height of the area of the source to 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 into database Function Start
if (empty($error)) {
    $sql = "INSERT INTO `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 INTO `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 An error occured. Please Try Again</div>";
                    }
                // INSERT Social Data END
        } else {
                $error_display = "<div class='errormsgbox'>2 An error occured. Please Try Again</div>";
        }

} else { //Erros Display '
        $error_show =  '';
        foreach ($error as $key => $values) {
            $error_show .=' <li>'. $values.'</li>'; 
            $error_display = "<div class='errormsgbox'> <ol>".$error_show."</ol></div>";      
        }
}
// INSERT values into database Function End
}
?>

$conn连接变量集在哪里?您没有结果表单查询,因此可能这就是问题所在

如果插入查询生成错误,只需检查它:

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

你的脚本在哪里?那是你所有的代码或其他东西?你不认为你应该分享你得到的错误吗?刚刚更新了帖子请检查我的脚本我得到了错误什么错误?正如我已经提到的,一切正常,但有时我得到了这个错误,在第156行我得到了这个结果你有一个错误在SQL语法中;查看与您的MySQL服务器版本对应的手册,以获取正确的语法,因为在描述字段中有特殊字符,所以我认为我遇到了错误