为什么PHP和MySQL脚本无法在Raspberry Pi服务器上运行?

时间:2015-06-17 17:16:59

标签: php mysql raspberry-pi

我正在运行Debian 7(Wheezy),在我的Raspberry Pi上发布7.8。我安装了Apache 2,安装了PHP(版本5.4)和MySQL(版本5.5)作为我的服务器。带有一些HTML的simpe PHP脚本按预期工作。

但是,带有数据库查询的PHP脚本在我的Raspberry Pi服务器上不起作用。例如,在提交表单时,页面只刷新重置表单,但似乎根本不执行SQL查询。当我使用WAMP在我的PC上测试相同的脚本时,脚本似乎运行良好。

为什么会这样?在将PHP脚本上传到我的Raspberry Pi服务器(基于Linux)的服务器之前,是否需要对其进行任何修改?

我在Raspberry Pi Web服务器上启用了display_errors功能,但我看不到任何错误消息。

HTML / PHP

<?php
    # mysqli_connect.php

    // This file contains the database access information.
    /* This file also establishes a connection to MySQL, selects the
    database and sets the encoding.*/

    // Set the database access information as
    // constants:
    //
    //     DEFINE('DB_USER', 'root');
    //     DEFINE('DB_PASSWORD', 'password');
    //     DEFINE('DB_HOST', 'localhost');
    //     DEFINE('DB_NAME', 'test_db');

    // Make the connections:
    $dbc = @mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) OR
        die ('Could not connect to MYSQL: ' . mysqli_connect_error() ); ?>

查询是:

$q = "INSERT INTO users (first_name, last_name, email, country, biography, registration_date) VALUES ('$first_name', '$last_name', '$email', '$country', '$biography', NOW() )"; aaaaaa

$r = @mysqli_query($dbc, $q);

我可以从Raspberry Pi上的命令行连接到MySQL。该表存在于MySQL数据库中,我正在使用具有正确用户权限的“root”用户。 PHP扩展名是mysqli。

尝试在我的Raspberry Pi上设置WordPress时遇到了同样的问题。设置的PHP脚本无法正常执行。

0 个答案:

没有答案