dqc2017 2016-09-28 16:21
浏览 31
已采纳

插入数据时如何修复PHP错误

I want create Android application, in my application I want send comment from app to server! For server side I write this code, but when running PHP code show me this error:

The site.com page isn’t working

site.com is currently unable to handle this request.
HTTP ERROR 500

For connect to the database I write this code:

<?php
    define('HOST', 'localhost');
    define('USER', 'userName');
    define('PASS', 'password');
    define('DB', 'databseName');

    $con = mysqli_connect(HOST, USER, PASS, DB);

    if($con){
        echo "Connection success ...";
    } else {
        echo "Connection Failed ...";
    }
?>

When running this file (dbConnect.php) show me "Connection success ...".

For insert to the database I write below codes:

<?php
    require "dbConnect.php";

    $comment_ID = ;
    $comment_post_ID = 2289;
    $comment_author = "test name";
    $comment_author_email = "emailTest@gmail.com";
    $comment_author_url = "";
    $comment_author_IP = 0;
    $comment_date = 2016-09-28;
    $comment_date_gmt = 2016-09-28;
    $comment_content = "This is one test comment with PHP code";
    $comment_karma = 0;
    $comment_approved = 0;
    $comment_agent = "";
    $comment_type = ;
    $comment_parent = 0;
    $user_id = 0;

    $sql_query = "INSERT INTO qpHskU_comments VALUES ('$comment_ID', '$comment_post_ID', '$comment_author', '$comment_author_email',
                 '$comment_author_url', '$comment_author_IP', '$comment_date', '$comment_date_gmt', '$comment_content',
                 '$comment_karma', '$comment_approved', '$comment_agent', '$comment_type', '$comment_parent', '$user_id');";

    if(mysqli_query($con,$sql_query)){
        echo "Record added successfully.";
    } else {
        echo "Record not added..." . mysqli_error($con);
    }

?>

Insert file name is (insertComment.php), when running this file (site.com/insertComment.php) show me this error!

The site.com page isn’t working

site.com is currently unable to handle this request.
HTTP ERROR 500

How can I fix it? I am amateur in PHP!

  • 写回答

1条回答 默认 最新

  • dongyu3967 2016-09-28 16:42
    关注

    The error 500 is due to a failure of PHP to parse successfully your code

    Replace

    $comment_ID = ;
    ....
    $comment_type = ;
    

    With

    $comment_ID = "";
    ....
    $comment_type = "";
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 本题的答案是不是有问题
  • ¥15 关于#r语言#的问题:(svydesign)为什么在一个大的数据集中抽取了一个小数据集
  • ¥15 C++使用Gunplot
  • ¥15 这个电路是如何实现路灯控制器的,原理是什么,怎么求解灯亮起后熄灭的时间如图?
  • ¥15 matlab数字图像处理频率域滤波
  • ¥15 在abaqus做了二维正交切削模型,给刀具添加了超声振动条件后输出切削力为什么比普通切削增大这么多
  • ¥15 ELGamal和paillier计算效率谁快?
  • ¥15 蓝桥杯单片机第十三届第一场,整点继电器吸合,5s后断开出现了问题
  • ¥15 file converter 转换格式失败 报错 Error marking filters as finished,如何解决?
  • ¥15 Arcgis相交分析无法绘制一个或多个图形