mysql - PHP 中的 SQL 查询和输出不起作用 - 500 内部服务器错误

标签 mysql sql output internal-server-error

我尝试将一个有效的 SQL 查询放入我的 Cronjob 的 PHP 文件中。但我只收到一个空白的 500 内部服务器错误通知。

SQL 查询在 PHPmyAdmin 中运行良好。

这里是代码:

<?php
    $con=mysqli_connect("HOST","DBUSER","DBPW","DBNAME");
    // Check connection
    if (mysqli_connect_errno())
      {
      echo "Failed to connect to MySQL: " . mysqli_connect_error();
      }

    $result = mysqli_query($con,"SELECT oc_order_product.order_id AS bestellnr, oc_order_product.quantity, oc_order_product.model, oc_order_product.name, oc_order.shipping_company, oc_order.shipping_firstname, oc_order.shipping_lastname, oc_order.shipping_city
FROM oc_order_product, oc_order
WHERE oc_order.order_id = oc_order_product.order_id
AND oc_order.order_status_id = 1
ORDER BY bestellnr, model");

    while($row = mysqli_fetch_array($result))
      {
      echo $row['oc_order_product.order_id'] . "; " . $row['oc_order_product.quantity'] "; " . $row['oc_order_product.model'] "; " . $row['oc_order_product.name'] "; " . $row['oc_order.shipping_company'] "; " . $row['oc_order.shipping_firstname'] "; " . $row['oc_order.shipping_lastname'] "; " . $row['oc_order.shipping_city']; //these are the fields that you have stored in your database table
      echo "<br />";
      }

    mysqli_close($con);
    ?>

error_log 为空。我的代码有问题吗? 我通过邮件收到的错误消息:

状态:500 内部服务器错误 X-Powered-By: PHP/5.6.19 内容类型:文本/html;字符集=UTF-8

有什么想法吗? 谢谢

最佳答案

我注意到这是不正确的:

$row['oc_order_product.order_id']

该行没有具有该名称的列。事实上,您已经明确地为该列指定了名称 bestellnr。所以,您可以尝试:

$row['bestellnr']

不过,我不能保证这是唯一的问题。

关于mysql - PHP 中的 SQL 查询和输出不起作用 - 500 内部服务器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40485390/

相关文章:

mysql - 我想获取主表的 Id 但获取 null 并尝试获取非对象的属性

sql - 将 SQL 表行与同一表的所有其他行连接起来

c - 应用 free() 后节点的值?

mysql - 如何在mysql中插入一些公式?

MySQL查询性能提升

mysql - 如何使用 mysljs 在 mySql 和 node.js 中批量插入

php - 动态表单字段创建并保存在数据库php mysql中

sql - TSQL 多列索引

c# - 无法理解 lambda 表达式输出

C程序,终端没有打印