上传到数据库时出现奇怪的错误

时间:2016-02-16 19:33:14

标签: php android mysql

我正在创建与MySQL数据库连接的应用程序,我已经在我的域上有一些工作的PHP文件,但现在我通常不能使用1个PHP文件。
PHP文件看起来像这样:

<?php
    $response = array();

    require_once __DIR__ . '/db_connect.php';

    $db = new DB_CONNECT();

    if(isset($_POST['title']) && isset($_POST['dish']) && isset($_POST['review']) && isset($_POST['rating']) && isset($_POST['database_name']) && isset($_POST['UserKeyID']) && isset($_POST['dishphoto']) && isset($_POST['dishsmallphoto'])) {

        $title = $_POST['title'];
        $dish = $_POST['dish'];
        $review = $_POST['review'];
        $rating = $_POST['rating'];
        $database_name = $_POST['database_name'];
        $UserKeyID = $_POST['UserKeyID'];
        $dishphoto = $_POST['dishphoto'];
        $dishsmallphoto = $_POST['dishsmallphoto'];

        $result = mysql_query("INSERT INTO " . $database_name . "(title, review, rating, dish, dishphoto, dishsmallphoto, UserKeyID) VALUES('$title', '$review', '$rating', '$dish', '$dishphoto', '$dishsmallphoto', '$UserKeyID')");

        if ($result) {
            $response["success"] = 1;
                $response["message"] = "Product successfully created.";

                // echoing JSON response
                echo json_encode($response);
        } else {
            $response["success"] = 0;
                $response["message"] = "Oops! An error occurred.";

                // echoing JSON response
                echo json_encode($response);
        }

    } else {
        $response["success"] = 0;
            $response["message"] = "Required field(s) is missing";

            // echoing JSON response
            echo json_encode($response);
    }
?>

在logcat中有类似的东西:

[socket][/] connected
[CDS]rx timeout:0
[CDS]SO_SND_TIMEOUT:0
>doSendRequest
<doSendRequest

0 个答案:

没有答案