Esempio n. 1
0
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>";
    }
}
Esempio n. 2
0
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;
    }
}
Esempio n. 3
0
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!");
}
Esempio n. 4
0
%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;
}
Esempio n. 5
0
<?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;
    }
Esempio n. 6
0
    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("&amp;", "&", htmlspecialchars(trim($str), ENT_QUOTES));
    //return str_replace(",", "&#044", $newcode);
}
function DecodeHTMLTag($str)
{
    return str_replace("&amp;", "&", $str);
}
if (!function_exists('htmlspecialchars_decode')) {
<?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();
}
Esempio n. 8
0
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);
}
Esempio n. 9
0
        $new_password="******";
        $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 = "******";
//$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='******' 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";