dtd58256 2019-03-27 10:59
浏览 298
已采纳

如何修复以不反映到http:// localhost / phpmyadmin /即本地主机的形式提交的值

I have a form(Insert new post here) where I am trying to post the entered values to the localhost. I couldn't see my values entered in my local host. I am getting the following error: "Error in response to storage.get: Syntax Error: Unexpected token at Object.callback". To resolve it I have cleared the browser cache and application cache but cannot resolve.

I have added the following debug int the PHP code but this is not reflecting:

echo "<script>alert('Product has been inserted')</script>";

PHP Code:

 <?php  
   if(isset($POST['insert_post'])){
        //getting the text data from fields
        $product_title = $_POST['product_title'];
        $product_cat = $_POST['product_cat'];
        $product_brand = $_POST['product_brand'];
        $product_price = $_POST['product_price'];
        $product_desc = $_POST['product_desc'];
        $product_keywords = $_POST['product_keywords'];
        //getting the image from the fields
        $product_image = $_FILES['product_image']['name'];
        $product_image_tmp = $_FILES['product_image']['tmp_name'];
        //uploading an image  
         move_uploaded_file
        ($product_image_tmp,"product_images/$product_image");
         echo $insert_product="insert into products   
         (product_cat,
          product_brand,       
          product_title,
          product_price,
          product_desc,
          product_image,
          product_keywords)
        values      
        (
        '$product_cat',
        '$product_brand',
        '$product_title',
        '$product_price',
        '$product_desc',
        '$product_image',
        '$product_keywords'
        )";
        $insert_pro = mysqli_query($con,$insert_product);
        if($insert_pro){
        echo "<script>alert('Product has been inserted')</script>";  
        echo "<script>window('insert_product.php','_self')</script>";}
   }
?>

I expect to get an alert as "Product has been inserted" but at present I am not getting it. Once I get it the inserted data will be saved to the local host.[entered_value_in_the_form]

  • 写回答

1条回答 默认 最新

  • douli8428 2019-03-27 11:06
    关注

    Is the php function executed in an async call? If so, you shouldn't echo the $insert_product variable, otherwise, you may get syntax errors.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效