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 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据
  • ¥20 软件测试决策法疑问求解答