准备好MYLSQI插入不起作用,没有错误消息

时间:2017-08-27 16:21:15

标签: php mysqli

您好我的问题是:当我尝试将表单发布到我的mysql数据库时我没有错误但是帖子没有记录到我的表中 PS:帖子是通过jquery FormData

发送的
<?php

require_once("../dist/includes/connexion.php");




$error = "";
$c_name =  htmlspecialchars(addslashes($_POST["c_name"]));
$c_pname = htmlspecialchars(addslashes($_POST["c_pname"]));
$c_date_n = htmlspecialchars(addslashes($_POST["c_date_n"]));
$c_sex = htmlspecialchars(addslashes($_POST["c_sex"]));
$c_age = htmlspecialchars(addslashes($_POST["c_age"]));
$c_address = htmlspecialchars(addslashes($_POST["c_address"]));
$c_taille = htmlspecialchars(addslashes($_POST["c_taille"]));
$c_poid = htmlspecialchars(addslashes($_POST["c_poid"]));
$c_tel = $_POST["c_tel"];
$c_mail = htmlspecialchars(addslashes($_POST["c_mail"]));
$c_facebook = htmlspecialchars(addslashes($_POST["c_facebook"]));
$c_twitter = htmlspecialchars(addslashes($_POST["c_twitter"]));
$c_youtube = htmlspecialchars(addslashes($_POST["c_youtube"]));
$c_linkidin = htmlspecialchars(addslashes($_POST["c_linkidin"]));
$c_experiance = $_POST["c_experiance"];
$c_comments = $_POST["c_comments"];
$c_peau = htmlspecialchars(addslashes($_POST["c_peau"]));
$c_yeux = htmlspecialchars(addslashes($_POST["c_yeux"]));
$c_cheveux = htmlspecialchars(addslashes($_POST["c_cheveux"]));
$c_interer = htmlspecialchars(addslashes($_POST["c_interer"]));
$c_photo = $_FILES["c_photo"];
$name_array = $_FILES['c_photo']['name'];
$tmp_name_array = $_FILES['c_photo']['tmp_name'];
$type_array = $_FILES['c_photo']['type'];
$size_array = $_FILES['c_photo']['size'];
$error_array = $_FILES['c_photo']['error'];

if($c_name&$c_pname){

    $SQLFindClients = "SELECT c_name, c_pname FROM condidats WHERE c_name = ? AND c_pname = ?";

    $STMTFindClients = $connect->stmt_init();

    if(!$STMTFindClients->prepare($SQLFindClients)){
        $error = mysqli_error($connect);
        echo $error;
        //echo '<meta http-equiv="refresh" content="0; index.php" />';
        exit();
    }
    else {

        $STMTFindClients->bind_param('ss' , $c_name, $c_pname);

        $STMTFindClients->execute();

        $ResultFindClients = $STMTFindClients->get_result();

        $RowsFindClients = $ResultFindClients->num_rows;



    if($RowsFindClients <= 0 ){


        $c_tels = array();  
        foreach($c_tel as $key =>  $m ){
            $c_tels[] = htmlspecialchars($m);
        }

        $c_photos = array();    
        foreach($name_array as $key1 =>  $fi ){
            $c_photos[] = htmlspecialchars($fi);
        }
        for($i = 0; $i < count($tmp_name_array); $i++){
            move_uploaded_file($tmp_name_array[$i], "../condidats_photos/".$name_array[$i]);
        }

        $SQLinsertClient =  "INSERT INTO condidats (c_id, c_name, c_pname, c_sex, c_date_n,  c_age, c_address, c_tel, c_mail, c_peau, c_yeux, c_cheveux, c_taille, c_poid, c_photo, c_interer, c_facebook, c_twitter, c_youtube, c_linkidin,  c_experiance, c_comments) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ";    


        //$SQLinsertClient = "INSERT INTO condidats (c_name) VALUES (?) ";


        $STMTinsertClient = $connect->stmt_init();

        if(!$STMTinsertClient->prepare($SQLinsertClient)){
            $error = mysqli_error($connect);
            echo $error;
            //echo '<meta http-equiv="refresh" content="0; index.php"/>';
            exit();
        }
        else {

            $Client_idvide = "";

            $c_tels = mysqli_real_escape_string($connect, implode(', ',$c_tels));

            $c_photos = mysqli_real_escape_string($connect, implode(', ',$c_photos));                   

            $STMTinsertClient->bind_param('ssssssssssssssssssssss', $Client_idvide, $c_name, $c_pname, $c_sex, $c_date_n, $c_age, $c_address, $c_tels, $c_mail, $c_peau, $c_yeux, $c_cheveux, $c_taille, $c_poid, $Client_idvide, $c_interer,  $c_facebook, $c_twitter, $c_youtube,  $c_linkidin, $c_experiance, $c_comments);

        //$STMTinsertClient->bind_param('s', $c_name);
        $STMTinsertClient->execute();


        echo '
          <div class="box box-solid">
            <div class="box-header with-border info">
              <h3 class="box-title">Succéeses...</h3>
              <div class="box-tools">
                <button class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
              </div>
            </div>
            <div class="box-body no-padding">
              <ul class="nav nav-pills nav-stacked">
                <li class="active"><a> Votre inscription a était bien effectuer   : <b>'.stripslashes(stripslashes($c_name)).' '.stripslashes(stripslashes($c_pname)).' '.$error.' '.$RowsFindClients.'</b></a></li>
              </ul>
            </div><!-- /.box-body -->
          </div>

          <script>
            $("#myModal").removeClass()
            $("#myModal").addClass(\'modal modal-success fade\');
          </script>
          ';
        }                           
    }

    else {
        echo '
          <div class="box box-solid">
            <div class="box-header with-border info">
              <h3 class="box-title">Erreur...</h3>
              <div class="box-tools">
                <button class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
              </div>
            </div>
            <div class="box-body no-padding">
              <ul class="nav nav-pills nav-stacked">
                <li class="active"><a><b>Ce Condidat existe déjà</b></a></li>
              </ul>
            </div><!-- /.box-body -->
          </div>


          <script>
            $("#myModal").removeClass()
            $("#myModal").addClass(\'modal modal-warning fade\');
          </script>

          ';
        }
    }
}           

else {
    echo '
      <div class="box box-solid">
        <div class="box-header with-border info">
          <h3 class="box-title">Erreur...</h3>
          <div class="box-tools">
            <button class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
          </div>
        </div>
        <div class="box-body no-padding">
          <ul class="nav nav-pills nav-stacked">
            <li class="active"><a><b>Assurez vous que tous les champs sont bien remplis</b></a></li>
          </ul>
        </div><!-- /.box-body -->
      </div>

      <script>
        $("#myModal").removeClass()
        $("#myModal").addClass(\'modal modal-warning fade\');
      </script>
  ';
    }

&GT;

1 个答案:

答案 0 :(得分:0)

你好Akintunde的相关代码:

                                                $SQLinsertClient =  "INSERT INTO condidats (c_id, c_name, c_pname, c_sex, c_date_n,  c_age, c_address, c_tel, c_mail, c_peau, c_yeux, c_cheveux, c_taille, c_poid, c_photo, c_interer, c_facebook, c_twitter, c_youtube, c_linkidin,  c_experiance, c_comments) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ";    


                            //$SQLinsertClient = "INSERT INTO condidats (c_name) VALUES (?) ";


                            $STMTinsertClient = $connect->stmt_init();

                            if(!$STMTinsertClient->prepare($SQLinsertClient)){
                                $error = mysqli_error($connect);
                                echo $error;
                                //echo '<meta http-equiv="refresh" content="0; index.php"/>';
                                exit();
                            }
                            else {

                                $Client_idvide = "";

                                $c_tels = mysqli_real_escape_string($connect, implode(', ',$c_tels));

                                $c_photos = mysqli_real_escape_string($connect, implode(', ',$c_photos));                   

                                $STMTinsertClient->bind_param('ssssssssssssssssssssss', $Client_idvide, $c_name, $c_pname, $c_sex, $c_date_n, $c_age, $c_address, $c_tels, $c_mail, $c_peau, $c_yeux, $c_cheveux, $c_taille, $c_poid, $Client_idvide, $c_interer,  $c_facebook, $c_twitter, $c_youtube,  $c_linkidin, $c_experiance, $c_comments);

                            //$STMTinsertClient->bind_param('s', $c_name);
                            $STMTinsertClient->execute();