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.

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

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘