当前位置: 首页>>代码示例>>PHP>>正文


PHP returnError函数代码示例

本文整理汇总了PHP中returnError函数的典型用法代码示例。如果您正苦于以下问题:PHP returnError函数的具体用法?PHP returnError怎么用?PHP returnError使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了returnError函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: sql

function sql($table)
{
    global $dbh;
    global $database;
    $data = array();
    foreach ($database[$table] as $field => $type) {
        if (!empty($_REQUEST[$field])) {
            $data[$field] = $_REQUEST[$field];
        } else {
            if (!empty($type[1])) {
                returnError("{$field} is required");
                exit;
            }
        }
    }
    $sql = 'insert into ' . $table . ' (';
    foreach ($data as $name => $value) {
        $sql .= '`' . $name . '`,';
    }
    $sql = substr($sql, 0, -1);
    $sql .= ') values (';
    foreach ($data as $name => $value) {
        $sql .= ':' . $name . ',';
    }
    $sql = substr($sql, 0, -1);
    $sql .= ')';
    $sth = $dbh->prepare($sql);
    $sth->execute($data);
    echo $sql;
}
开发者ID:Luisfmarkes,项目名称:socialturn,代码行数:30,代码来源:api.php

示例2: API_checkRequiredFields

function API_checkRequiredFields($requiredFields)
{
    // Globale Variablen einbinden
    global $apiResponseHeader;
    $error = false;
    $errorFields = '';
    $requestParams = array();
    $requestParams = $_REQUEST;
    // PUT-Methode abfangen
    if ($_SERVER['REQUEST_METHOD'] == 'PUT') {
        $api_internal = \Slim\Slim::getInstance();
        parse_str($app->request()->getBody(), $requestParams);
    }
    // Paramenter prüfen
    foreach ($requiredFields as $field) {
        if (!isset($requestParams[$field]) || strlen(trim($requestParams[$field])) <= 0) {
            $error = true;
            $errorFields .= $field . ', ';
        }
    }
    // Fehler ausgeben
    if ($error) {
        $api_internal = \Slim\Slim::getInstance();
        // API Ausgabe erzeugen
        $errorMsg = returnError('E0002', 'API-Internal-CheckFields');
        $apiResponseHeader['error'] = true;
        $apiResponseHeader['code'] = $errorMsg['code'];
        $apiResponseHeader['message'] = $errorMsg['message'] . ' (' . substr($errorFields, 0, -2) . ')';
        API_Response(200, '');
        // Ausführung anhalten
        $api_internal->stop();
    }
}
开发者ID:089,项目名称:FFNRW-PRGenerator,代码行数:33,代码来源:helper-checkRequiredFields.php

示例3: call

 public function call()
 {
     // Check if the user is logged in to your oauth system.
     if (false) {
         returnError("You must be logged into to use the API", 401, "user_not_logged_in");
         return;
     }
     // this line is required for the application to proceed
     $this->next->call();
 }
开发者ID:earl3s,项目名称:Boilderplate-php-REST-API,代码行数:10,代码来源:OAuthVerifyMiddleware.php

示例4: write

 public function write($id, $data)
 {
     if ($data == null) {
         return true;
     }
     $db = new database();
     $db->query("INSERT INTO tbl_session\n                  SET session_id = :id,\n                  session_data = :data\n                  ON DUPLICATE KEY UPDATE session_data = :data");
     $db->bind(':id', $id);
     $db->bind(':data', $data);
     try {
         $db->execute();
     } catch (Exception $e) {
         return returnError("Database error: " . $e->getMessage());
     }
 }
开发者ID:nfreader,项目名称:baseline,代码行数:15,代码来源:session.php

示例5: getUser

 public static function getUser($db)
 {
     $userName = $_SESSION['user_name'];
     // Check for existing user
     $getUserQuery = "SELECT user_id, user_name, name, avatar FROM user WHERE user_name = :userName";
     $statement = $db->prepare($getUserQuery);
     $statement->execute(array(":userName" => $userName));
     $results = $statement->fetch(PDO::FETCH_OBJ);
     if (!$results) {
         returnError("User is not in the system.", 401, 'user_not_added');
         return;
     }
     $results->user_id = intval($results->user_id);
     return $results;
 }
开发者ID:earl3s,项目名称:Boilderplate-php-REST-API,代码行数:15,代码来源:Users.php

示例6: errorHandler

function errorHandler($errorNum, $errorStr, $errorFile, $errorLine)
{
    $errorMsg = "Error {$errorNum}: {$errorStr} in {$errorFile}, line {$errorLine}.";
    $GLOBALS['swxLastErrorMessage'] = $errorMsg;
    // Display the error message in the PHP error log
    error_log($errorMsg);
    $errorObj = array('error' => TRUE, 'code' => $errorNum, 'message' => $errorMsg);
    //if ($errorNum == E_ERROR || $errorNum == E_WARNING || $errorNum = E_USER_ERROR)
    // Error num check replaced by code from http://drupal.org/node/11772#comment-18383.
    // This stops PHP5 strict errors from failing a call (e.g., deprecated calls, etc.)
    //if (($errorNum & (E_ALL & E_STRICT) ^ (E_NOTICE & E_STRICT)) || $errorNum = E_USER_ERROR)
    if ($errorNum != E_STRICT && $errorNum != E_NOTICE) {
        // On errors and warnings, stop execution and return the
        // error message to the client. This is a far better
        // alternative to failing silently.
        returnError($errorObj);
    }
}
开发者ID:hafizubikm,项目名称:bakeme,代码行数:18,代码来源:swx.php

示例7: login

function login($email, $password, $mysqli)
{
    if ($stmt = $mysqli->prepare("SELECT user_id, user_firstname, user_lastname, user_username, user_email, user_password, user_salt FROM users WHERE user_username = ? OR user_email = ?")) {
        $stmt->bind_param('ss', $email, $email);
        // Bind "$email" to parameter.
        $stmt->execute();
        // Führe die vorbereitete Anfrage aus.
        $stmt->store_result();
        // hole Variablen von result.
        $stmt->bind_result($user_id, $user_firstname, $user_lastname, $user_username, $user_email, $db_password, $salt);
        $stmt->fetch();
        // hash das Passwort mit dem eindeutigen salt.
        $password = hash('sha512', $password . $salt);
        if ($stmt->num_rows == 1) {
            // Überprüfe, ob das Passwort in der Datenbank mit dem vom
            // Benutzer angegebenen übereinstimmt.
            if ($db_password == $password) {
                $user_browser = $_SERVER['HTTP_USER_AGENT'];
                // Login erfolgreich.
                $login_string = hash('sha512', $password . $user_browser);
                $SQLquery = "UPDATE users ";
                $SQLquery .= "SET user_login_string = ? ";
                $SQLquery .= "WHERE user_id = ? ";
                if ($insert_stmt = $mysqli->prepare($SQLquery)) {
                    $insert_stmt->bind_param('ss', $login_string, $user_id);
                    if (!$insert_stmt->execute()) {
                        returnError("pL-0");
                    } else {
                        return $login_string;
                    }
                }
            } else {
                // Passwort ist nicht korrekt
                return false;
            }
        } else {
            //Es gibt keinen Benutzer.
            return false;
        }
    }
}
开发者ID:eWert-Online,项目名称:componentDB,代码行数:41,代码来源:processLogin.php

示例8: taskBot

function taskBot()
{
    global $db;
    $req = $db->prepare("SELECT * FROM Exports\n\t\t\tJOIN Formats ON ID_Format = ID_Format_Export\n\t\t\tWHERE Running_Export = 1");
    DBQuery($req, array());
    foreach ($req->fetchAll() as $d) {
        $statusfile = file("export/" . $d["Name_Export"] . "-status.txt", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
        if ($statusfile[count($statusfile) - 1] == "Blender quit") {
            // Export finished
            $name = uniqid("o") . "." . $d["Extension_Format"];
            $db->beginTransaction();
            $req = $db->prepare("INSERT INTO Outputs(ID_Export_Output, File_Output, DateCreate_Output)\n\t\t\t\t\tVALUES (:export, :name, NOW())");
            DBQuery($req, array("export" => $d["ID_Export"], "name" => $name));
            $req = $db->prepare("UPDATE Exports SET Running_Export = 0 WHERE ID_Export = :export");
            DBQuery($req, array("export" => $d["ID_Export"]));
            if (!copy("export/" . $d["Name_Export"] . "." . $d["Extension_Format"], "output/" . $name)) {
                returnError("Erreur lors de la copie");
            }
            $db->commit();
        }
    }
}
开发者ID:clarkwinkelmann,项目名称:easyblender,代码行数:22,代码来源:query.php

示例9: array

}
include_once '../includes/functions.php';
include_once '../includes/db_connect.php';
$SQLQuery = "  SELECT ";
$SQLQuery .= "     library_id, ";
$SQLQuery .= "     library_name, ";
$SQLQuery .= "     library_path, ";
$SQLQuery .= "     library_private, ";
$SQLQuery .= "     library_type ";
$SQLQuery .= " FROM ";
$SQLQuery .= "     libraries; ";
if ($stmt = $mysqli->prepare($SQLQuery)) {
    $stmt->execute();
    // Führe die vorbereitete Anfrage aus.
    $stmt->store_result();
    // hole Variablen von result.
    $stmt->bind_result($library_id, $library_name, $library_path, $library_private, $library_type);
    $arrReturn = array();
    $i = 0;
    while ($stmt->fetch()) {
        $arrReturn[$i]["id"] = $library_id;
        $arrReturn[$i]["name"] = $library_name;
        $arrReturn[$i]["path"] = $library_path;
        $arrReturn[$i]["type"] = $library_type;
        $arrReturn[$i]["private"] = $library_private;
        $i++;
    }
    echo json_encode($arrReturn);
} else {
    returnError($mysqli->error);
}
开发者ID:eWert-Online,项目名称:componentDB,代码行数:31,代码来源:getAllLibraries.php

示例10: returnError

if (!$link) {
    returnError(mysql_error($link));
}
if (!mysql_select_db($DATABASE, $link)) {
    returnError(mysql_error($link));
}
foreach ($_POST as $key => $value) {
    $args[$key] = mysql_real_escape_string($value);
}
if (!array_key_exists('title', $args) || !$args['title']) {
    returnError('Must provide a primary key.');
}
$query = "SELECT * FROM {$TABLE} WHERE `title`='{$args['title']}'";
$result = mysql_query($query, $link);
if (!$result) {
    returnError(mysql_error($link));
}
if (mysql_num_rows($result) > 0) {
    // item exists, update
    foreach (array('uri', 'date', 'done') as $value) {
        if (array_key_exists($value, $args)) {
            $tmp[] = sprintf('%s=\'%s\'', $value, $args[$value]);
        }
    }
    $tmp = implode(',', $tmp);
    if ($tmp) {
        $query = "UPDATE {$TABLE} SET {$tmp} WHERE title='{$args['title']}'";
        $result = mysql_query($query, $link);
    }
} else {
    // new item, insert
开发者ID:gitter-badger,项目名称:junkcode,代码行数:31,代码来源:save.php

示例11: hash

                // Generate a random salt
                $random_salt = hash('sha512', uniqid(openssl_random_pseudo_bytes(16), TRUE));
                // Create a password with the new password hash and the salt
                $password = hash('sha512', $new_password . $random_salt);
                // Update the users password and salt in the database
                $SQLquery = "UPDATE users SET ";
                $SQLquery .= "user_password = ?, user_salt = ? ";
                $SQLquery .= "WHERE user_id = ?";
                if ($update_stmt = $mysqli->prepare($SQLquery)) {
                    $update_stmt->bind_param('sss', $password, $random_salt, $user_id);
                    if (!$update_stmt->execute()) {
                        returnError("cP-3");
                    } else {
                        echo "true";
                    }
                } else {
                    returnError("cP-3");
                }
            } else {
                // Passwort ist nicht korrekt
                returnError("cP-2");
            }
        } else {
            //Es gibt keinen Benutzer.
            returnError("cP-1");
        }
    }
} else {
    // Die korrekten POST-Variablen wurden nicht zu dieser Seite geschickt.
    returnError("cP-0");
}
开发者ID:eWert-Online,项目名称:componentDB,代码行数:31,代码来源:changePassword.php

示例12: returnError

}
if (!$walls) {
    returnError("这里暂时没有墙。");
    return;
}
$ret = array();
while (list($key, $value) = each($walls)) {
    if (intval($key) > $limit) {
        break;
    }
    $info = WaWall::GetWallInfo($value['wall_id']);
    if (!$info) {
        continue;
    }
    $wall = array();
    $wall['wall_id'] = $info['wall_id'];
    $wall['wall_name'] = $info['wall_name'];
    $wall['wall_desc'] = $info['wall_desc'];
    $userInfo = WaUser::GetUserInfo($info['wall_creator']);
    if ($userInfo) {
        $wall['wall_creatorname'] = $userInfo['user_name'];
    }
    $wall['wall_type'] = $info['wall_type'];
    $wall['wall_usercount'] = $info['wall_usercount'];
    array_push($ret, $wall);
}
if ($ret) {
    echo json_encode($ret);
} else {
    returnError('暂无。');
}
开发者ID:bdbai,项目名称:wawall-sae,代码行数:31,代码来源:gethallwall.php

示例13: now

    $SQLquery .= "VALUES (?, ?, ?, ?, ?, ?, ?, '0', ? , ?, now())";
    if ($insert_stmt = $mysqli->prepare($SQLquery)) {
        $insert_stmt->bind_param('sssssssss', $project_Id, $project_Title, $project_HTML, $project_CSS, $project_JS, $project_Tags, $project_Description, $arrResult[0]["version"], $project_Owner);
        if (!$insert_stmt->execute()) {
            returnError("Das Projekt konnte nicht in der Datenbank gespeichert werden.");
        } else {
            if (isset($_POST['projectLibraries'])) {
                $project_newID = $mysqli->insert_id;
                $project_libraries = $_POST['projectLibraries'];
                $error = false;
                foreach ($project_libraries as $key => $val) {
                    if ($library_stmt = $mysqli->prepare("INSERT INTO project_has_library (project_id, library_id) VALUES(?, ?)")) {
                        $library_stmt->bind_param('ss', $project_newID, $val);
                        if (!$library_stmt->execute()) {
                            $error = true;
                        }
                    }
                }
                if (!$error) {
                    echo "true";
                } else {
                    returnError("Es konnten nicht alle Bibliotheken mit dem Projekt verknüpft werden.");
                }
            } else {
                echo "true";
            }
        }
    } else {
        returnError("Das Projekt konnte nicht in der Datenbank gespeichert werden.");
    }
}
开发者ID:eWert-Online,项目名称:componentDB,代码行数:31,代码来源:saveProject.php

示例14: executeDbQuery

function executeDbQuery($db, $query, $device, $reading, $timeRange, $maxCount)
{
    try {
        $stmt = $db->prepare($query);
        $stmt->bindValue(':device', $device, PDO::PARAM_STR);
        $stmt->bindValue(':reading', $reading, PDO::PARAM_STR);
        // Check if request is initial request or update
        if (!isset($_POST['update'])) {
            $stmt->bindValue(':timeRange', $timeRange);
        }
        $stmt->bindValue(':count', $maxCount);
        $stmt->execute();
    } catch (PDOException $pe) {
        returnError($pe->getMessage());
    }
    return $stmt;
}
开发者ID:revil-O,项目名称:db_plot_widget,代码行数:17,代码来源:widget_dbplot.php

示例15: returnError

        if ($stmt = $mysqli->prepare("SELECT user_email FROM users WHERE user_email = ?")) {
            $stmt->bind_param('s', $changed_value);
            $stmt->execute();
            // Führe die vorbereitete Anfrage aus.
            $stmt->store_result();
            if ($stmt->num_rows > 0) {
                //check if username is used already
                returnError("Username bereits vergeben");
            } else {
                if ($updatestmt = $mysqli->prepare("UPDATE users SET user_email = ? WHERE user_login_string = ?")) {
                    $updatestmt->bind_param('ss', $changed_value, $client_login_string);
                    if ($updatestmt->execute()) {
                        echo "true";
                    }
                } else {
                    returnError("E-Mail Adresse konnte nicht aktualisiert werden.");
                }
            }
        } else {
            returnError("Email konnte nicht geprüft werden!");
        }
        break;
    case "profilepic":
        if ($stmt = $mysqli->prepare("UPDATE users SET user_firstname = ? WHERE user_login_string = ?")) {
            $stmt->bind_param('ss', $changed_value, $client_login_string);
            echo "profilepic";
        } else {
            returnError("Profilbild konnte nicht gespeichert werden!");
        }
        break;
}
开发者ID:eWert-Online,项目名称:componentDB,代码行数:31,代码来源:changeUserDetails.php


注:本文中的returnError函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。