dougekui1518 2018-01-06 10:43
浏览 114

PHP连接到xampp失败

Heres my code in the php,

See as Text

if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
    include 'DatabaseConfig.php';

    $con = mysqli_connect($HostName, $HostUser, $HostPass, $DatabaseName);
    $Email = $_POST['User_Email'];
    $Password = $_POST['User_Password'];
    $Full_Name = $_POST['User_Full_Name'];
    $CheckSQL = "SELECT * FROM register_account WHERE User_Email='$Email'";
    $check = mysqli_fetch_array(mysqli_query($con, $CheckSQL));
    if (isset($check))
    {
        echo 'Email Already Exist, Please Enter Another Email.';
    }
    else
    {
        $Sql_Query = "INSERT INTO register_account values(User_Email,User_Password,User_Full_Name) values ('$Email','$Password','$Full_Name')";
        if (mysqli_query($con, $Sql_Query))
        {
            echo 'User Registration Successfully';
        }
        else
        {
            echo 'Something went wrong';
        }
    }
}

mysqli_close($con);

and here's the error when i try to check it on my browser

Notice: Undefined variable: con in C:\xampp\htdocs\android\User-Registration.php on line 36

Warning: mysqli_close() expects parameter 1 to be mysqli, null given in C:\xampp\htdocs\android\User-Registration.php on line 

i've checked my db and codes as many times as i cant but seems like still didnt work forme. can anyone help me out please? thanks!

  • 写回答

2条回答 默认 最新

  • douzhongpi9734 2018-01-06 10:48
    关注

    Well, check your code: you are only running mysqli_connect if a POST request occured, but you are running mysqli_close in every request

    评论

报告相同问题?

悬赏问题

  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
  • ¥15 乘性高斯噪声在深度学习网络中的应用