Я пытаюсь вставить данные в таблицу sql, но она показывает ошибку - PullRequest
0 голосов
/ 24 апреля 2020

Вот код, который я пытаюсь этот код. Весь код работает правильно, когда я удаляю столбец функций, но когда я снова добавляю столбец функций, он начинает выдавать ошибку. Я пытался изменить форму типа enctype, потому что я думаю, что ошибка из-за вставки данных html в базу данных sql. Я хочу, чтобы данные html были вставлены. здесь проблема в том, что он дает execeuting оператор else, когда я пытался с функциями столбец

<form action="addmovie.php" method="post" enctype="multipart/form-data" >
  <div class="form-group">
        <label for="email"> Url1:</label>
        <input type="text" placeholder="Mobilephone.pk URL" name="url3" class="form-control" id="email" ></input></div>

         <div class="form-group">
          <label for="email"> Thumbnail URL (GSMARENA.COM):</label>
        <input type="text" placeholder="thumbnail url (GSMARENA)" name="thumbnail" class="form-control" id="email" ></input></div>

         <label for="email"> Category:</label>


            <select class="form-control"  name="category" >
           <?php
                include('../db/connection.php');
                  $query=mysqli_query($conn,"select * from category");

                while($row=mysqli_fetch_array($query)){


                  ?>
               <option value="<?php echo $row['category_name'];?>"><?php echo $row['category_name'];?></option>

                 <?php } ?>
            </select>
            </div>
         <input type="submit" name="submit1" class="btn btn-primary" value="Submit">
      </form>

 <?php

include('../db/connection.php');
if (isset($_POST['submit1'])) {

  $url3=$_POST['url3'];

   $thumbnail=$_POST['thumbnail'];

   $category=$_POST['category'];
  ?>      
<?php
include "../simple_html_dom.php";
$html=file_get_html("$url3");
$title = $html->find("h1#head1",0)->plaintext;
$price = $html->find("p.bold",0)->plaintext;

$html1=file_get_html("$url3");
$features = $html1->find("ul#features",0)->innertext;
$desdt0 = $html1->find("div.specs_table",0)->innertext;
$desdt1 = $html1->find("div.specs_table",1)->innertext;
$desdt2 = $html1->find("div.specs_table",3)->innertext;

$desdt3 = $html1->find("div.specs_table",4)->innertext;


$desdt4 = $html1->find("div.specs_table",5)->innertext;

$desdt5 = $html1->find("div.specs_table",6)->innertext;

$desdt6 = $html1->find("div.specs_table",7)->innertext;

$desdt7 = $html1->find("div.specs_table",8)->innertext;

$desdt8 = $html1->find("div.specs_table",9)->innertext;

$desdt9 = $html1->find("div.specs_table",10)->innertext;

$desdt10 = $html1->find("div.specs_table",11)->innertext;
}




?>
</p>
<?php
include('../db/connection.php');
if (isset($_POST['submit1'])) {
  $query1=mysqli_query($conn,"insert into myposts (title,price,desdt0,desdt1,desdt2,desdt3,desdt4,desdt5,desdt6,desdt7,desdt8,desdt9,desdt10,thumbnail,category,features) values('$title','$price','$desdt0','$desdt1','$desdt2','$desdt3','$desdt4','$desdt5','$desdt6','$desdt7','$desdt8','$desdt9','$desdt10','$thumbnail','$category','$features')");
   if ($query1) {
        # code...
        echo "<script>alert('News uploaded Successfully !!')</script>  ";
     }else{
        echo "<script>alert('Please Try Again!!')</script>  ";

     }

}
 ?>
...