本文整理汇总了PHP中connect_mysql函数的典型用法代码示例。如果您正苦于以下问题:PHP connect_mysql函数的具体用法?PHP connect_mysql怎么用?PHP connect_mysql使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了connect_mysql函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create_range_search_result
function create_range_search_result()
{
connect_mysql();
$sql = "SELECT `id`, `prange` FROM `q5_products_range`";
$result = mysql_query($sql);
while ($rs = mysql_fetch_array($result)) {
echo "<option value='" . $rs['id'] . "'>" . ucwords($rs['prange']) . "</option>";
}
}
示例2: query_write_mysql
function query_write_mysql($sql, $mysqli)
{
global $host_info;
if ($mysqli->query($sql)) {
return true;
}
/* We assign last errno to variable as somehow it is being cleared
after first call */
$errno = $mysqli->errno;
printf("ERRROR: %s [%d] %s on line %d\n", $host_info, $errno, $mysqli->error, __LINE__);
if (is_connect_error($errno)) {
$mysqli = connect_mysql(true, $mysqli);
return query_write_mysql($sql, $mysqli);
} else {
return false;
}
}
示例3: connect_mysql
function connect_mysql()
{
$mysql_host = HOST_PRIMARY;
$connected = true;
if (is_file('/tmp/PRIMARY_HAS_FAILED')) {
$mysql_host = HOST_STANDBY;
}
$mysqli = false;
$mysqli = mysqli_init();
$mysqli->real_connect($mysql_host, "msandbox", "msandbox", "test");
/* https://bugs.php.net/bug.php?id=67564 */
$mysqli->query('/*ms=master*/SELECT 1');
if (!$mysqli->thread_id) {
$connected = false;
}
$retries = 1;
while (!$connected and $retries <= 10) {
printf("Connection to host '{$mysql_host}' failed: [%d] %s, " . "retrying ({$retries} of 10) in 3 seconds\n", $mysqli->connect_errno, $mysqli->error);
sleep(3);
$mysqli = false;
$mysqli = mysqli_init();
$mysqli->real_connect($mysql_host, "msandbox", "msandbox", "test");
$mysqli->query('/*ms=master*/SELECT 1');
if (!$mysqli->thread_id) {
$connected = false;
} else {
$connected = true;
break;
}
$retries++;
}
if (!$connected and $retries >= 10 and $mysql_host == HOST_PRIMARY) {
printf("The primary host '{$mysql_host}' has failed after 30 seconds, " . "failing over to standby!\n");
touch('/tmp/PRIMARY_HAS_FAILED');
return connect_mysql();
}
if ($connected) {
return $mysqli;
}
/* if we get at this point, neither the primary nor secondary has failed */
die("Could not get MySQL connection!");
}
示例4: sprintf
%sThe script ran in %0.3f seconds.
SHC Manager
MESSAGE;
$body = sprintf($message, $err, (isset($report) and $report != '') ? sprintf(<<<REPORT
Additionally, the following report was made prior to exiting:
%s
REPORT
, $report) : '', microtime(true) - $time);
echo "<pre>{$body}</pre>";
mail($admin_address, "Error running check_posters.php", $body, "From:{$admin_address}\r\n");
exit(1);
}
$mysqli = connect_mysql();
if (!$mysqli) {
report_error("Could not connect to database.");
}
$mysqli->query("USE {$mysql_dbname};");
$query = "SELECT id, thread_url FROM days WHERE\n thread_url IS NOT NULL";
$stmt = $mysqli->prepare($query);
if (!$stmt) {
report_error(sprintf("Could not prepare day selection statement (error %d)", $mysqli->errno));
}
$stmt->execute();
$stmt->bind_result($id, $url);
$urls = array();
while ($stmt->fetch()) {
$urls[$id] = $url;
}
示例5: isset
<?php
require_once 'lib/settings.php';
require_once 'lib/db.php';
require_once 'lib/users.php';
require_once 'lib/session.php';
require_once 'lib/login.php';
require_once 'lib/voc.php';
if (!connect_mysql()) {
exit;
}
$time = isset($_GET['t']) ? intVal($_GET['t']) : 0;
if (isset($_GET['d']) && isset($_GET['m']) && isset($_GET['y'])) {
$d = intVal($_GET['d']);
$m = intVal($_GET['m']);
$y = intVal($_GET['y']);
if ($d < 1) {
$d = 1;
}
if ($m < 1) {
$m = 1;
}
if ($y < 0) {
$y = 0;
}
if ($d > 31) {
$d = 31;
}
if ($m > 12) {
$m = 12;
}
示例6: mysql_query
mysql_query('SET CHARACTER SET utf8', $link_id);
}
function close_mysql()
{
global $link_id;
mysql_close($link_id);
}
function loadsqlkey($array_s, $array_v)
{
$str_key = "";
for ($i = 0; $i < count($array_s); $i++) {
$str_key .= "&" . $array_s[$i] . "=" . urlencode($array_v[$i]);
}
return $str_key;
}
connect_mysql();
if (!$link_id) {
die("The Server is now very busy! Please try again later!");
}
mysql_select_db($config["db_server"]['db']);
mysql_query('SET CHARACTER SET utf8', $link_id);
function EncodeHTMLTag($str)
{
return str_replace("&", "&", htmlspecialchars(trim($str), ENT_QUOTES));
//return str_replace(",", ",", $newcode);
}
function DecodeHTMLTag($str)
{
return str_replace("&", "&", $str);
}
if (!function_exists('htmlspecialchars_decode')) {
示例7: connect_mysql
<?php
/******
* MySQL connection library
******/
require_once 'config.php';
function connect_mysql()
{
$database = mysql_connect(DB_HOST, DB_USER, DB_PASS) or die;
mysql_select_db(DB_NAME, $database);
return $database;
}
if (!$database) {
$database = connect_mysql();
}
示例8: delete_list
function delete_list($form_list_id)
{
$dbc = connect_mysql();
$q = 'delete from list where list_id=?';
$stmt = mysqli_prepare($dbc, $q);
mysqli_stmt_bind_param($stmt, 'i', $list_id);
$list_id = $form_list_id;
mysqli_stmt_execute($stmt);
mysqli_stmt_close($stmt);
mysqli_close($dbc);
}
示例9: var_dump
$new_password="123456";
$json_message=changepassword($new_password);
$message=json_decode($json_message);
echo $message->changepassword;*/
//echo $json_message;
/*$message['login']='成功';
$json_message=json_encode($message,JSON_UNESCAPED_UNICODE);
echo $json_message;
var_dump($json_message);
$a=json_decode($json_message);
echo $a->login;
$arr = array ('a'=>urlencode('芒果小站'));
echo urldecode(json_encode($arr));*/
$dbc = connect_mysql();
//$name="孙岩";
$name = null;
$password = "123456sy";
//$q="select * from usermessage where (name=$name or name is null)and(password=$password or $password is null)";
$q = "select * from usermessage where 1=1 and (name='{$name}'or name is null)and(password='{$password}' or password is null)";
//$q="select * from usermessage where name is null";
$r = mysqli_query($dbc, $q);
if ($r) {
echo "success";
while ($row = mysqli_fetch_array($r)) {
echo $row["name"];
echo $row['password'];
}
} else {
echo "fail";