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


PHP mysqli_sqlstate函数代码示例

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


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

示例1: createWebinar

/**
 * Fetch the $_POST vars and format into JSON 
 * to POST to GoToWebinar
 *  Return value is a webinar key
 * Also, write vals into webinars db
 */
function createWebinar()
{
    global $globalCurlOptions, $db;
    $startDateAry = explode("/", $_POST['startDate']);
    $startTimeAry = explode(":", $_POST['startTime']);
    $startTS = mktime($startTimeAry[0], $startTimeAry[1], 0, $startDateAry[0], $startDateAry[1], $startDateAry[2]);
    $duration = $_POST['duration'] * 60 * 60;
    $endTS = $startTS + $duration;
    $description = $_POST['presenter'] . "\r\n" . $_POST['description'];
    $webinarDetails = array("subject" => $_POST['title'], "description" => $description, "times" => array(array("startTime" => date("c", $startTS), "endTime" => date("c", $endTS))), "timeZone" => $_POST['timezone']);
    $tokenAry = getAuthToken("gtw");
    $accessToken = $tokenAry['access_token'];
    $organizerKey = $tokenAry['organizer_key'];
    $webinarInfo = json_encode($webinarDetails);
    $ch = curl_init();
    $url = "https://api.citrixonline.com:443/G2W/rest/organizers/" . $organizerKey . "/webinars";
    $headers = array("Authorization: " . $accessToken, "Accept: application/json", "Content-Type: application/json; charset=UTF-8", "Content-Length: " . strlen($webinarInfo));
    curl_setopt_array($ch, $globalCurlOptions);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $webinarInfo);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    $result = curl_exec($ch);
    $mtgInfo = json_decode($result, TRUE);
    $webinarKey = $mtgInfo['webinarKey'];
    // Add to DB
    $q = "INSERT INTO webinars SET\n       title        =    '" . mysqli_real_escape_string($db, $_POST['title']) . "',\n       presenter    =    '" . mysqli_real_escape_string($db, $_POST['presenter']) . "',\n       description  =    '" . mysqli_real_escape_string($db, $_POST['description']) . "',\n       startTime    =    '" . date("Y-m-d H:i:00", $startTS) . "',\n       endTime      =    '" . date("Y-m-d H:i:00", $endTS) . "',\n       timezone     =    '" . $_POST['timezone'] . "',\n       campaignID   =    '" . $_POST['campaignID'] . "',\n       webinarKey   =    '{$webinarKey}'";
    if (!mysqli_query($db, $q)) {
        printf("Error: %s\n", mysqli_sqlstate($db));
    }
    mysqli_close($db);
    echo "<p>Webinar key {$webinarKey} has been created</p>";
}
开发者ID:nightbeacons,项目名称:gtw-events,代码行数:38,代码来源:index.php

示例2: dump_properties

function dump_properties($mysqli)
{
    printf("\nClass variables:\n");
    $variables = array_keys(get_class_vars(get_class($mysqli)));
    sort($variables);
    foreach ($variables as $k => $var) {
        printf("%s = '%s'\n", $var, var_export(@$mysqli->{$var}, true));
    }
    printf("\nObject variables:\n");
    $variables = array_keys(get_object_vars($mysqli));
    foreach ($variables as $k => $var) {
        printf("%s = '%s'\n", $var, var_export(@$mysqli->{$var}, true));
    }
    printf("\nMagic, magic properties:\n");
    assert(@mysqli_affected_rows($mysqli) === @$mysqli->affected_rows);
    printf("mysqli->affected_rows = '%s'/%s ('%s'/%s)\n", @$mysqli->affected_rows, gettype(@$mysqli->affected_rows), @mysqli_affected_rows($mysqli), gettype(@mysqli_affected_rows($mysqli)));
    assert(@mysqli_get_client_info() === @$mysqli->client_info);
    printf("mysqli->client_info = '%s'/%s ('%s'/%s)\n", @$mysqli->client_info, gettype(@$mysqli->client_info), @mysqli_get_client_info(), gettype(@mysqli_get_client_info()));
    assert(@mysqli_get_client_version() === @$mysqli->client_version);
    printf("mysqli->client_version =  '%s'/%s ('%s'/%s)\n", @$mysqli->client_version, gettype(@$mysqli->client_version), @mysqli_get_client_version(), gettype(@mysqli_get_client_version()));
    assert(@mysqli_errno($mysqli) === @$mysqli->errno);
    printf("mysqli->errno = '%s'/%s ('%s'/%s)\n", @$mysqli->errno, gettype(@$mysqli->errno), @mysqli_errno($mysqli), gettype(@mysqli_errno($mysqli)));
    assert(@mysqli_error($mysqli) === @$mysqli->error);
    printf("mysqli->error = '%s'/%s ('%s'/%s)\n", @$mysqli->error, gettype(@$mysqli->error), @mysqli_error($mysqli), gettype(@mysqli_error($mysqli)));
    assert(@mysqli_field_count($mysqli) === @$mysqli->field_count);
    printf("mysqli->field_count = '%s'/%s ('%s'/%s)\n", @$mysqli->field_count, gettype(@$mysqli->field_count), @mysqli_field_count($mysqli), gettype(@mysqli_field_count($mysqli)));
    assert(@mysqli_insert_id($mysqli) === @$mysqli->insert_id);
    printf("mysqli->insert_id = '%s'/%s ('%s'/%s)\n", @$mysqli->insert_id, gettype(@$mysqli->insert_id), @mysqli_insert_id($mysqli), gettype(@mysqli_insert_id($mysqli)));
    assert(@mysqli_sqlstate($mysqli) === @$mysqli->sqlstate);
    printf("mysqli->sqlstate = '%s'/%s ('%s'/%s)\n", @$mysqli->sqlstate, gettype(@$mysqli->sqlstate), @mysqli_sqlstate($mysqli), gettype(@mysqli_sqlstate($mysqli)));
    assert(@mysqli_get_host_info($mysqli) === @$mysqli->host_info);
    printf("mysqli->host_info = '%s'/%s ('%s'/%s)\n", @$mysqli->host_info, gettype(@$mysqli->host_info), @mysqli_get_host_info($mysqli), gettype(@mysqli_get_host_info($mysqli)));
    /* note that the data types are different */
    assert(@mysqli_info($mysqli) == @$mysqli->info);
    printf("mysqli->info = '%s'/%s ('%s'/%s)\n", @$mysqli->info, gettype(@$mysqli->info), @mysqli_info($mysqli), gettype(@mysqli_info($mysqli)));
    assert(@mysqli_thread_id($mysqli) > @$mysqli->thread_id);
    assert(gettype(@$mysqli->thread_id) == gettype(@mysqli_thread_id($mysqli)));
    printf("mysqli->thread_id = '%s'/%s ('%s'/%s)\n", @$mysqli->thread_id, gettype(@$mysqli->thread_id), @mysqli_thread_id($mysqli), gettype(@mysqli_thread_id($mysqli)));
    assert(@mysqli_get_proto_info($mysqli) === @$mysqli->protocol_version);
    printf("mysqli->protocol_version = '%s'/%s ('%s'/%s)\n", @$mysqli->protocol_version, gettype(@$mysqli->protocol_version), @mysqli_get_proto_info($mysqli), gettype(@mysqli_get_proto_info($mysqli)));
    assert(@mysqli_get_server_info($mysqli) === @$mysqli->server_info);
    printf("mysqli->server_info = '%s'/%s ('%s'/%s)\n", @$mysqli->server_info, gettype(@$mysqli->server_info), @mysqli_get_server_info($mysqli), gettype(@mysqli_get_server_info($mysqli)));
    assert(@mysqli_get_server_version($mysqli) === @$mysqli->server_version);
    printf("mysqli->server_version = '%s'/%s ('%s'/%s)\n", @$mysqli->server_version, gettype(@$mysqli->server_version), @mysqli_get_server_version($mysqli), gettype(@mysqli_get_server_version($mysqli)));
    assert(@mysqli_warning_count($mysqli) === @$mysqli->warning_count);
    printf("mysqli->warning_count = '%s'/%s ('%s'/%s)\n", @$mysqli->warning_count, gettype(@$mysqli->warning_count), @mysqli_warning_count($mysqli), gettype(@mysqli_warning_count($mysqli)));
    printf("\nAccess to undefined properties:\n");
    printf("mysqli->unknown = '%s'\n", @$mysqli->unknown);
    @($mysqli->unknown = 13);
    printf("setting mysqli->unknown, @mysqli_unknown = '%s'\n", @$mysqli->unknown);
    $unknown = 'friday';
    @($mysqli->unknown = $unknown);
    printf("setting mysqli->unknown, @mysqli_unknown = '%s'\n", @$mysqli->unknown);
    printf("\nAccess hidden properties for MYSLQI_STATUS_INITIALIZED (TODO documentation):\n");
    assert(@mysqli_connect_error() === @$mysqli->connect_error);
    printf("mysqli->connect_error = '%s'/%s ('%s'/%s)\n", @$mysqli->connect_error, gettype(@$mysqli->connect_error), @mysqli_connect_error(), gettype(@mysqli_connect_error()));
    assert(@mysqli_connect_errno() === @$mysqli->connect_errno);
    printf("mysqli->connect_errno = '%s'/%s ('%s'/%s)\n", @$mysqli->connect_errno, gettype(@$mysqli->connect_errno), @mysqli_connect_errno(), gettype(@mysqli_connect_errno()));
}
开发者ID:alphaxxl,项目名称:hhvm,代码行数:59,代码来源:mysqli_class_mysqli_properties_no_conn.php

示例3: _session_post_finish

function _session_post_finish($link, $logData)
{
    require 'config_files.php';
    // finish the session specified in the request
    $finishTime = time();
    $finishTimeText = date('Y-m-d H:i:s', $finishTime);
    // TODO: Need to check to see if this has been closed, already.
    //   if so, return an error, otherwise, update the record.
    $thisParam = 'sessionId';
    if (array_key_exists($thisParam, $logData)) {
        if (!is_numeric($logData[$thisParam])) {
            $badParam[$thisParam] = "Not a number";
        } else {
            $sessionId = $logData[$thisParam];
        }
    } else {
        $badParam[$thisParam] = "Missing";
    }
    if (empty($badParam)) {
        // close the task 0 record for this session
        $query = 'UPDATE ' . $DB_TABLE_SESSION_LOG . ' SET endTime = "' . $finishTimeText . '" WHERE sessionId = ' . $sessionId . ' AND taskId = 0';
        $result = mysqli_query($link, $query);
        // $response['debug']['query'] = $query;
        // $response['debug']['result'] = $result;
        if ($result) {
            $rData = array();
            $rData['sessionId'] = $sessionId;
            $rData['finishTime'] = $finishTimeText;
            $response['data'] = $rData;
        } else {
            $localErr = '';
            $localErr['sqlQuery'] = $query;
            $localErr['result'] = 'Error finishing session_log entry';
            $localErr['sqlError'] = mysqli_sqlstate($link);
            $localErr['message'] = mysqli_error($link);
            $errData['update1'] = $localErr;
        }
    } else {
        // a bad parameter was passed
        $localErr = '';
        $localErr['message'] = 'Bad parameter in request.';
        $localErr['paramError'] = $badParam;
        $localErr['request'] = $logData;
        // $localErr['globals'] = $GLOBALS;
        $errData['validation'] = $localErr;
    }
    if (!empty($errData)) {
        $response['error'] = $errData;
    }
    return $response;
}
开发者ID:rbwatson,项目名称:wlux_test_server,代码行数:51,代码来源:session_post_finish.php

示例4: _gratuity_get_studyId

function _gratuity_get_studyId($link, $logData)
{
    require 'config_files.php';
    // check the parameters
    $thisParam = 'studyId';
    if (!is_numeric($logData)) {
        $badParam[$thisParam] = "Not a number";
    } else {
        $studyId = $logData;
    }
    if (empty($badParam)) {
        // read conifguration for this study and condition
        $query = 'SELECT * FROM ' . $DB_TABLE_GRATUITY_LOG . ' WHERE studyId = ' . $studyId;
        $result = mysqli_query($link, $query);
        $idx = 0;
        if (mysqli_num_rows($result) > 0) {
            while ($thisRecord = mysqli_fetch_assoc($result)) {
                // remove the recordSeq field
                unset($thisRecord['recordSeq']);
                $response['data'][$idx] = array_merge($thisRecord);
                foreach ($response['data'][$idx] as $k => $v) {
                    // set "null" strings to null values
                    if ($v == 'NULL') {
                        $response['data'][$k] = NULL;
                    }
                }
                $idx += 1;
            }
        }
        if ($idx == 0) {
            $localErr = '';
            $localErr['sqlQuery'] = $query;
            $localErr['result'] = 'No gratuity records found';
            $localErr['sqlError'] = mysqli_sqlstate($link);
            $localErr['message'] = mysqli_error($link);
            $errData['queryData'] = $localErr;
            $response['error'] = $errData;
        }
    } else {
        // bad parameter in request data
        $errData['message'] = 'studyId is missing from the query string.';
        $errData['paramError'] = $badParam;
        $errData['request'] = $logData;
        // $errData['globals'] = $GLOBALS;
        $response['error'] = $errData;
    }
    return $response;
}
开发者ID:rbwatson,项目名称:wlux_test_server,代码行数:48,代码来源:gratuity_get_studyid.php

示例5: _gratuity_post_gratuity

function _gratuity_post_gratuity($link, $logData)
{
    require 'config_files.php';
    // create a new gratuity_log record
    if (!empty($logData)) {
        // TODO: Chceck fields
        // add server-generated fields to insert query
        $dbColList = 'recordSeq';
        $dbValList = '0';
        // add the client-provided fields
        foreach ($logData as $dbCol => $dbVal) {
            isset($dbColList) ? $dbColList .= ', ' : ($dbColList = '');
            isset($dbValList) ? $dbValList .= ', ' : ($dbValList = '');
            $dbColList .= $dbCol;
            if (empty($dbVal) && strlen($dbVal) == 0) {
                $dbValList .= 'NULL';
            } else {
                $escapedString = str_replace("'", "''", $dbVal);
                $dbValList .= '\'' . $escapedString . '\'';
            }
        }
        $queryString = 'INSERT INTO ' . $DB_TABLE_GRATUITY_LOG . ' (' . $dbColList . ') VALUES (' . $dbValList . ')';
        $qResult = mysqli_query($link, $queryString);
        if (!$qResult) {
            // SQL ERROR
            $localErr = '';
            $localErr['sqlQuery'] = $queryString;
            $localErr['result'] = 'Error creating session_config record';
            $localErr['sqlError'] = mysqli_sqlstate($link);
            $localErr['message'] = mysqli_error($link);
            $errData['insert1'] = $localErr;
            $response['error'] = $errData;
        } else {
            // finish start response buffer
            $response['data'] = $logData;
        }
    }
    return $response;
}
开发者ID:rbwatson,项目名称:wlux_test_server,代码行数:39,代码来源:gratuity_post_gratuity.php

示例6: get_sql_array

 public function get_sql_array($sql)
 {
     $arr = array();
     //Это должно помочь восстанавливать соединения если они разорвались
     $this->reconnect();
     $result = mysqli_query($this->sql_interface, $sql);
     //echo $sql;
     if (!$result) {
         $error_no = mysqli_errno($this->sql_interface);
         $error_text = mysqli_error($this->sql_interface);
         $sqlstate_text = mysqli_sqlstate($this->sql_interface);
         $this->mastdie(0, "сдох при чтении :( - " . $sqlstate_text . "  Error: {$error_no}:" . $error_text . "  SQL:" . $sql);
     }
     try {
         while ($row = $result->fetch_assoc()) {
             $arr[] = $row;
         }
         mysqli_free_result($result);
     } catch (Exception $e) {
         $this->echo_log($e);
     }
     return $arr;
 }
开发者ID:aatk,项目名称:ESB,代码行数:23,代码来源:ex_class.class.php

示例7: install

 public function install(&$err_list, $script_file_name = '')
 {
     $err_list = array();
     if ($script_file_name == '') {
         $script_file_name = Kohana::$config->load('install.install_sql_script_name');
     }
     Helper::set_installation_status(INSTALLING);
     $a = Helper::get_install_settings();
     $link = @mysqli_connect($a['db_path'], $a['db_login'], $a['db_password'], $a['db_name']);
     if (!$link) {
         //throw new Exception($message, $code, $previous)
         $err_list[0]['error'] = __('Error connecting to MySQL') . ' №' . mysqli_connect_errno() . ': ' . mysqli_connect_error() . '.';
         return false;
     } else {
         //			mysqli_query($link,'SET NAMES utf8');
         $i = 0;
         $a = file($script_file_name);
         $a = Arr::map('trim', $a);
         foreach ($a as $n => $l) {
             if (substr($l, 0, 2) == '--' or $l == '') {
                 unset($a[$n]);
             }
         }
         $a = explode(";\n", implode("\n", $a));
         //unset($a[count($a)-1]);
         foreach ($a as $n => $q) {
             if ($q) {
                 if (!mysqli_query($link, $q)) {
                     $err_list[$i]['errno'] = mysqli_errno($link);
                     $err_list[$i]['sqlstate'] = mysqli_sqlstate($link);
                     $err_list[$i]['error'] = mysqli_error($link);
                     $i++;
                 }
             }
         }
         $q = 'INSERT INTO `roles` (`id`, `name`, `description`) VALUES' . '(1, \'login\', \'Login privileges, granted after account confirmation\'),' . '(2, \'admin\', \'Administrative user, has access to everything.\');';
         if (!mysqli_query($link, $q)) {
             $err_list[$i]['errno'] = mysqli_errno($link);
             $err_list[$i]['sqlstate'] = mysqli_sqlstate($link);
             $err_list[$i]['error'] = mysqli_error($link);
             $i++;
         }
         $install = Helper::get_install_settings();
         $q = 'INSERT INTO users (id,username, password) VALUES (1,"' . $install['installer_login'] . '","' . Auth::instance()->hash($install['installer_password']) . '")';
         if (!mysqli_query($link, $q)) {
             $err_list[$i]['errno'] = mysqli_errno($link);
             $err_list[$i]['sqlstate'] = mysqli_sqlstate($link);
             $err_list[$i]['error'] = mysqli_error($link);
             $i++;
         }
         $q = 'INSERT INTO `roles_users` (`user_id`, `role_id`) VALUES (1, 1),(1, 2);';
         if (!mysqli_query($link, $q)) {
             $err_list[$i]['errno'] = mysqli_errno($link);
             $err_list[$i]['sqlstate'] = mysqli_sqlstate($link);
             $err_list[$i]['error'] = mysqli_error($link);
             $i++;
         }
         //			@mysqli_multi_query($link,$c);
         //
         //			while (mysqli_more_results($link)) {
         //				$result = mysqli_next_result($link);
         //				$discard = mysqli_store_result($link);
         //				//if (!$result){
         //				if (mysqli_errno($link)){
         //					$err_list[$i]['errno']=mysqli_errno($link);
         //					$err_list[$i]['sqlstate']=mysqli_sqlstate($link);
         //					$err_list[$i]['error']=mysqli_error($link);
         //					$i++;
         //				}
         //			}
         if ($i == 0) {
             Helper::set_installation_status(INSTALLED);
         }
         return $i == 0 ? true : false;
     }
 }
开发者ID:g-a-g,项目名称:its2015,代码行数:76,代码来源:install.php

示例8: register

    $todate = $_POST['to'];
    $roomtype = $_POST['rtype'];
    $adults = $_POST['adults'];
    $children = $_POST['children'];
    $roomno = $_POST['rno'];
    if ($con) {
        $qdb = "SELECT * FROM register WHERE roomno = '{$roomno}';";
        $ds = "INSERT INTO register(name, email, phone, fromdate, todate, rtype, ano, cno, roomno) VALUES('{$name}', '{$email}', '{$phone}', '{$fromdate}', '{$todate}', '{$roomtype}', '{$adults}', '{$children}', '{$roomno}');";
        $check = mysqli_query($con, $qdb);
        $find = mysqli_num_rows($check);
        if ($find == 0) {
            $query = mysqli_query($con, $ds);
            if ($query) {
                echo "<p><center> Thank You !</center></p>";
            } else {
                echo "Error !" . mysqli_sqlstate($con);
            }
        } else {
            header("Location:nobook.html");
        }
    } else {
        echo " Couldn't get to DB";
    }
}
?>


<!DOCTYPE html>
<html>
<link rel="stylesheet" type="text/css" href="book.css">
<head><title> Booking successful </title></head>
开发者ID:abhi-r3v0,项目名称:Accommodation-Management-System,代码行数:31,代码来源:book.php

示例9: errorCode

 /**
  * Renvoi le code de la dernière erreur
  *
  */
 public function errorCode()
 {
     if (is_object($this->id)) {
         $code = mysqli_sqlstate($this->id);
         return empty($code) ? null : $code;
     }
 }
开发者ID:Qwaseur,项目名称:SACoche,代码行数:11,代码来源:DB_driver_mysqli.class.php

示例10: _study_get_allids

function _study_get_allids($link, $logData)
{
    require 'config_files.php';
    //test request type
    if ($logData['studyId'] == '*') {
        // return the specified configuration
        $query = 'SELECT DISTINCT studyId FROM ' . $DB_TABLE_STUDY_CONFIG;
        $result = mysqli_query($link, $query);
        $recordIndex = 0;
        $response['data']['count'] = mysqli_num_rows($result);
        if ($response['data']['count'] > 0) {
            while ($thisRecord = mysqli_fetch_assoc($result)) {
                $response['data']['studyIds'][$recordIndex] = $thisRecord['studyId'];
                $recordIndex = $recordIndex + 1;
            }
        } else {
            $localErr = '';
            $localErr['sqlQuery'] = $query;
            $localErr['result'] = 'Reading study config returned ' . mysqli_num_rows($result) . ' records';
            $localErr['sqlError'] = mysqli_sqlstate($link);
            $localErr['message'] = mysqli_error($link);
            $errData['query'] = $localErr;
            $response['error'] = $errData;
        }
    } else {
        //get the details for a specific study
        // check the parameters
        $thisParam = 'studyId';
        if (empty($logData[$thisParam]) || !is_numeric($logData[$thisParam])) {
            $badParam[$thisParam] = "Missing or not a number";
        } else {
            $studyId = $logData[$thisParam];
        }
        if (empty($badParam)) {
            // return the specified configuration
            $query = 'SELECT DISTINCT taskId, conditionId FROM ' . $DB_TABLE_STUDY_CONFIG . ' WHERE studyId = ' . $studyId;
            $result = mysqli_query($link, $query);
            $lastTaskId = -1;
            $conditionIdCount = 0;
            if (mysqli_num_rows($result) > 0) {
                $response['data']['studyId'] = $studyId;
                $response['data']['conditionCount'] = 0;
                $response['data']['conditionsBalanced'] = true;
                $response['data']['count'] = 0;
                while ($thisRecord = mysqli_fetch_assoc($result)) {
                    if ($lastTaskId != $thisRecord['taskId']) {
                        // set up for a new task
                        $lastTaskId = $thisRecord['taskId'];
                        $conditionIdCount = 0;
                        $response['data']['count'] = $response['data']['count'] + 1;
                    }
                    $response['data']['tasks'][$thisRecord['taskId']][$conditionIdCount] = $thisRecord['conditionId'];
                    $conditionIdCount = $conditionIdCount + 1;
                }
                // test task and condition symmetry: each task should have the same conditions
                // look for a difference. They shoud all be the same length
                $lastConditionCount = -1;
                foreach ($response['data']['tasks'] as $thisTask) {
                    if ($lastConditionCount == -1) {
                        $lastConditionCount = count($thisTask);
                    } else {
                        if ($lastConditionCount != count($thisTask)) {
                            $response['data']['conditionsBalanced'] = false;
                        }
                    }
                }
                if ($response['data']['conditionsBalanced'] == true) {
                    $response['data']['conditionCount'] = $lastConditionCount;
                }
            } else {
                $localErr = '';
                $localErr['sqlQuery'] = $query;
                $localErr['result'] = 'Reading study config returned ' . mysqli_num_rows($result) . ' records';
                $localErr['sqlError'] = mysqli_sqlstate($link);
                $localErr['message'] = mysqli_error($link);
                $errData['query'] = $localErr;
                $response['error'] = $errData;
            }
        } else {
            // bad parameter in request data
            $errData['message'] = 'Bad parameter in request.';
            $errData['paramError'] = $badParam;
            $errData['request'] = $logData;
            // $errData['globals'] = $GLOBALS;
            $response['error'] = $errData;
        }
    }
    return $response;
}
开发者ID:rbwatson,项目名称:wlux_test_server,代码行数:89,代码来源:study_get_allids.php

示例11: log_get_allids

function log_get_allids($link, $logData)
{
    require 'config_files.php';
    $response['debug']['logData'] = $logData;
    if ($logData['studyId'] == '*') {
        // return the specified configuration
        $query = 'SELECT DISTINCT s.studyId FROM ' . $DB_TABLE_SESSION_CONFIG . ' AS s JOIN ' . $DB_TABLE_TRANSITION_LOG . '  AS l' . ' WHERE l.sessionId = s.sessionId ORDER BY l.sessionId';
        $result = mysqli_query($link, $query);
        $recordIndex = 0;
        $response['data']['count'] = mysqli_num_rows($result);
        if ($response['data']['count'] > 0) {
            while ($thisRecord = mysqli_fetch_assoc($result)) {
                $response['data']['studyIds'][$recordIndex] = $thisRecord['studyId'];
                $recordIndex = $recordIndex + 1;
            }
        } else {
            $localErr = '';
            $localErr['sqlQuery'] = $query;
            $localErr['result'] = 'Reading study config returned ' . mysqli_num_rows($result) . ' records';
            $localErr['sqlError'] = mysqli_sqlstate($link);
            $localErr['message'] = mysqli_error($link);
            $errData['query'] = $localErr;
            $response['error'] = $errData;
        }
    } else {
        //get the details for a specific study
        // check the parameters
        $thisParam = 'studyId';
        if (empty($logData[$thisParam]) || !is_numeric($logData[$thisParam])) {
            $badParam[$thisParam] = "Missing or not a number";
        } else {
            $studyId = $logData[$thisParam];
        }
        if (empty($badParam)) {
            // return the specified configuration
            $query = 'SELECT DISTINCT s.sessionId, l.taskId FROM ' . $DB_TABLE_SESSION_CONFIG . ' AS s JOIN ' . $DB_TABLE_TRANSITION_LOG . '  AS l' . ' WHERE l.sessionId = s.sessionId AND s.studyId = ' . $studyId . ' ORDER BY l.sessionId, l.taskId';
            $result = mysqli_query($link, $query);
            if (mysqli_num_rows($result) > 0) {
                $response['data']['studyId'] = $studyId;
                $response['data']['count'] = 0;
                while ($thisRecord = mysqli_fetch_assoc($result)) {
                    $response['data']['sessionIds'][$thisRecord['sessionId']][] = $thisRecord['taskId'];
                }
                $response['data']['count'] = count($response['data']['sessionIds']);
            } else {
                $localErr = '';
                $localErr['sqlQuery'] = $query;
                $localErr['result'] = 'Reading study config returned ' . mysqli_num_rows($result) . ' records';
                $localErr['sqlError'] = mysqli_sqlstate($link);
                $localErr['message'] = mysqli_error($link);
                $errData['query'] = $localErr;
                $response['error'] = $errData;
            }
        } else {
            // bad parameter in request data
            $errData['message'] = 'Bad parameter in request.';
            $errData['paramError'] = $badParam;
            $errData['request'] = $logData;
            // $errData['globals'] = $GLOBALS;
            $response['error'] = $errData;
        }
    }
    return $response;
}
开发者ID:rbwatson,项目名称:wlux_test_server,代码行数:64,代码来源:log_get_allids.php

示例12: users

    $sql = "INSERT INTO users(firstname,lastname,email) VALUES('{$firstname}','{$lastname}','{$email}')";
    // If result is anything other than true then there's an error
    if (mysqli_query($link, $sql)) {
        // Create a flash message showing the user that it worked
        flash_message('alert alert-success', 'You are registered.');
        //redirect to the home page
        header("Location: index.php");
    } else {
        // we shouldn't get here unless there's an error
        // Error 1062 is a specific error that means "this email already exists in the system, emails must be unique"
        // Since we're "catching" this error we can display a custom error message and continue on our way
        if (mysqli_errno($link) == 1062) {
            flash_message('alert alert-danger', 'That email already exists.');
        } else {
            // This is for all other errors. It is less friendly. It just prints the error message that the server returns"
            printf("Error: %s\n", mysqli_sqlstate($link));
        }
    }
    // It always a good idea to close the link to the server/database when you are done
    // In big projects this can improve your site's performance
    mysqli_close($link);
}
?>

<!DOCTYPE html>
<html lang="en">
	<?php 
include_once 'head.php';
?>

  <body class="homepage">
开发者ID:eugenehiggins,项目名称:php-demo,代码行数:31,代码来源:register.php

示例13: set_driver_error

 public function set_driver_error($state = null, $mode = PDO::ERRMODE_SILENT, $func = '')
 {
     if ($state === null) {
         $state = mysqli_sqlstate($this->link);
     }
     $this->set_error(mysqli_errno($this->link), mysqli_error($this->link), $state, $mode, $func);
 }
开发者ID:Deepab23,项目名称:clinic,代码行数:7,代码来源:mysqli.php

示例14: json_encode

                // format and send output
                $fnResponse = $jsonpTag . '(' . json_encode($thisRecord) . ')';
            } else {
                // no callback param name so return an error
                // this line only works on PHP > 5.4.0, which not everyone seems to have.
                //   http_response_code(500);
                // this works on PHP > 4.3 (or so)
                $response['data'] = $thisRecord;
            }
        }
    } else {
        if (!headers_sent()) {
            header('content-type: application/json');
            header('X-PHP-Response-Code: 200', true, 200);
        }
        $errData['message'] = mysqli_error($link);
        $errData['sqlQuery'] = $query_string;
        $errData['sqlError'] = mysqli_sqlstate($link);
        $response['error'] = $errData;
    }
    if (!headers_sent()) {
        header('content-type: application/json');
        header('X-PHP-Response-Code: 200', true, 200);
    }
    if (!empty($fnResponse)) {
        print $fnResponse;
    } else {
        print json_encode($response);
    }
    mysqli_close($link);
}
开发者ID:rbwatson,项目名称:wlux_test_server,代码行数:31,代码来源:study_data.php

示例15: die

    die("Error opening database: " . mysqli_connect_error());
}
echo "Creating a new table ...", PHP_EOL;
// drop table if there is one already, then create a new one
mysqli_query($con, "DROP TABLE IF EXISTS Places");
mysqli_query($con, "CREATE TABLE Places(id INT NOT NULL AUTO_INCREMENT\r\n                     , PRIMARY KEY(id)\r\n                     , City VARCHAR(50) CHARACTER SET utf8 COLLATE utf8_general_ci\r\n                     , District VARCHAR(50) CHARACTER SET utf8 COLLATE utf8_general_ci\r\n                     , Type VARCHAR(50) CHARACTER SET utf8 COLLATE utf8_general_ci\r\n                     , Name VARCHAR(150) CHARACTER SET utf8 COLLATE utf8_general_ci\r\n                     , Speciality VARCHAR(150) CHARACTER SET utf8 COLLATE utf8_general_ci\r\n                     , Address VARCHAR(150) CHARACTER SET utf8 COLLATE utf8_general_ci\r\n                     , Phone1 VARCHAR(50) CHARACTER SET utf8 COLLATE utf8_general_ci\r\n                     , Phone2 VARCHAR(50) CHARACTER SET utf8 COLLATE utf8_general_ci\r\n                     , Fax VARCHAR(50) CHARACTER SET utf8 COLLATE utf8_general_ci )") or die(mysql_error());
echo "Saving places in database ...", PHP_EOL;
$count = 0;
foreach ($sheetData as $rec) {
    $count += 1;
    if ($count == 1) {
        continue;
    }
    // skip data row
    $City = $rec['A'];
    $District = $rec['B'];
    $Type = $rec['C'];
    $Name = $rec['D'];
    $Speciality = $rec['E'];
    $Address = $rec['F'];
    $Phone1 = $rec['G'];
    $Phone2 = $rec['H'];
    $Fax = $rec['I'];
    $sql = "INSERT INTO Places\r\n          (City, District, Type, Name, Speciality, Address, Phone1, Phone2, Fax)\r\n          VALUES\r\n          ('{$City}', '{$District}', '{$Type}', '{$Name}', '{$Speciality}', '{$Address}', '{$Phone1}', '{$Phone2}', '{$Fax}')";
    if (!mysqli_query($con, $sql)) {
        die("Could not save place #{$count}: " . mysqli_sqlstate());
    }
    echo ".";
}
echo PHP_EOL;
echo "Done! Total places: {$count}", PHP_EOL;
开发者ID:MahmoudAdly,项目名称:alico,代码行数:31,代码来源:process_alico.php


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