dongming8867 2017-07-29 14:49
浏览 54
已采纳

我的PHP和MySQL脚本在本地工作得很好,但不在我的实时网站上

I have a script on my website which handles a notification system for messages, and alerts. This script pulls in the data from a MySQL Database, and it works like a charm locally, but on my live site, the query fails. This script always returns false and goes to the else condition live, but locally it works exactly the way it should.

$queryNots = 'Select message, DATE_FORMAT(timeSent, "%h:%i %p %W, %M %D ") timeSent FROM notifications WHERE UserID="' . $userId . '" AND seen="n";';
if ($result = $con->query ($query)) {
    $resultNum = mysqli_num_rows ( $result );
    echo '<h2>You have ' . $resultNum . ' Notifications</h2>
            <ul>';
    while ( $row = $result->fetch_assoc () ) {
        echo '<li>' . $row ["message"] . ' @ ' . $row ['timeSent'] . '</li>';
    }
    if ($resultNum > 0) {
        echo '
            </ul>
                <form method="post" action="deleteNots.php">
                    <input type="hidden" name="curID" value="' . $userId . '">
                    <input type="submit" value="Dismiss">
                </form>
            ';
    }
} else {
    echo '<h2>Error reading table</h2>';
}

On the live site if I take out the if-else and just run the query not only does it fail, it kills the entire script. I have no idea what could be causing this, I know the tables are the same, because I use them in a different script just fine.

I have absolutely nothing to work with, because it isn't giving me any sort of MySQL error message to go off of. I really want to get this figured out because I want to have this site back working as soon as possible.

  • 写回答

2条回答 默认 最新

  • dougu1990 2019-04-12 16:12
    关注

    The solution to my issue ended up coming in the comments of the question, so I couldn't mark it as completed.

    try echo mysql_error() to see what´s going on there – handsome Jul 29 '17 at 14:51

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序