本文整理汇总了PHP中sql_connect函数的典型用法代码示例。如果您正苦于以下问题:PHP sql_connect函数的具体用法?PHP sql_connect怎么用?PHP sql_connect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sql_connect函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sql_query
function sql_query($sql)
{
sql_connect();
$res = mysql_query($sql);
$array = array();
while ($row = mysql_fetch_assoc($res)) {
$array[] = $row;
}
return $array;
}
示例2: __construct
function __construct($pagename)
{
set_error_handler("debug_handler");
if (ini_get("magic_quotes_gpc") !== false and get_magic_quotes_gpc()) {
modify::stripslashes($_REQUEST);
}
if (ini_get("register_globals")) {
modify::dropglobals();
}
@ignore_user_abort(0);
self::$time_start = sys_get_microtime();
if (!sql_connect(SETUP_DB_HOST, SETUP_DB_USER, sys_decrypt(SETUP_DB_PW, sha1(SETUP_ADMIN_USER)), SETUP_DB_NAME)) {
$err = sprintf("{t}Cannot connect to database %s on %s.{/t}\n", SETUP_DB_NAME, SETUP_DB_HOST) . sql_error();
trigger_error($err, E_USER_ERROR);
sys_die($err);
}
session_set_cookie_params(2592000);
// 1 month
session_name(SESSION_NAME);
session_set_save_handler("_login_session_none", "_login_session_none", "_login_session_read", "_login_session_none", "_login_session_destroy", "_login_session_none");
session_start();
header("Cache-Control: private, max-age=1, must-revalidate");
header("Pragma: private");
$this->template = new template();
$this->pagename = $pagename;
class_exists("modify");
// load class
}
示例3: db
function db($sql, $callback = '', $callbackNoResults = '')
{
//SQL CONNECT
$conn = sql_connect();
//SQL QUERY
$query = sql_query($conn, $sql);
//SQL CLOSE
$conn->close();
//CHECK CALLBACKS
if ($callback == '') {
return $query;
} else {
if ($query->num_rows > 0) {
if (sql_is_callback($callback) == true) {
return $callback;
} else {
while ($row = $query->fetch_assoc()) {
$callback($row);
}
}
} else {
if (sql_is_callback($callbackNoResults) == true) {
return $callbackNoResults;
} else {
$callbackNoResults();
}
}
}
}
示例4: article_add_to_db
function article_add_to_db($title, $content)
{
sql_connect();
$query = "INSERT INTO articles (article_title, article_content) VALUES ('" . $title . "', '" . $content . "')";
$temp = sql_query($query);
return $temp;
// return true if article succesfuly added to db, or false if not
}
示例5: sql_query
function sql_query($qry, &$conn = 0)
{
global $db;
// If no database connection is supplied use default
if (!$conn) {
$conn =& $db;
}
if (!$conn) {
print "NO DATABASE\n";
exit;
}
// check if connection was opened too long
if (isset($conn['date']) && time() - $conn['date'] > 3600) {
debug("connection {$conn['connection']} opened too long, closing", "sql");
$conn['date'] = null;
pg_close($conn['connection']);
unset($conn['connection']);
}
// check for database connection
sql_connect($conn);
// Rewrite SQL query
call_hooks("pg_sql_query", $qry, $conn);
// Do we want debug information?
if (isset($conn['debug']) && $conn['debug']) {
debug("CONN {$conn['title']}: " . $qry, "sql");
}
// Query
$res = pg_query($conn['connection'], $qry);
// There was an error - call hooks to inform about error
if ($res === false) {
// if postgresql connection died ...
if (pg_connection_status($conn['connection']) == PGSQL_CONNECTION_BAD) {
debug("sql connection died", "sql");
pg_close($conn['connection']);
unset($conn['connection']);
call_hooks("sql_connection_failed", $conn);
// if connection is back, retry query
if (isset($conn['connection']) && pg_connection_status($conn['connection']) == PGSQL_CONNECTION_OK) {
$res = pg_query($conn['connection'], $qry);
if ($res !== false) {
debug("sql retry successful", "sql");
return $res;
}
} else {
print "sql connection died\n";
exit;
}
}
$error = pg_last_error();
call_hooks("sql_error", $db, $qry, $error);
// If we want debug information AND we have an error, tell about it
if (isset($conn['debug']) && $conn['debug']) {
debug("CONN {$conn['title']}: " . pg_last_error(), "sql");
}
}
return $res;
}
示例6: sql_wrap
function sql_wrap()
{
global $g;
//if ($g["sql"]["connected"] == "true") return;
//$g["sql"]["connected"] = "true";
sql_connect();
sql_select();
return 0;
}
示例7: Sql_query
function Sql_query($sql)
{
sql_connect();
$res = mysql_query($sql);
$ret = [];
while (false !== ($row = mysql_fetch_assoc($res))) {
$ret[] = $row;
}
return $ret;
}
示例8: flogin
function flogin($a, $b)
{
sql_connect();
// Forming the sentence/string of query for qury function
$result = "SELECT * FROM users WHERE user_name='" . $a . "' AND user_password='" . $b . "'";
$temp = sql_query($result);
$arr = mysql_fetch_assoc($temp);
if ($arr !== false) {
return true;
} else {
return false;
}
}
示例9: note_post_to_db
function note_post_to_db($a, $b, $c)
{
sql_connect();
// geting string from entered by user post where \n is marked with full stop '.'
$post_arr = post_to_array($c);
$time = date('H:i:s', time()) . ' : ' . date('d-m-Y');
$temp = "INSERT INTO " . $a . " (user_note, user_note_title, user_note_time) " . "VALUES ('" . $post_arr . "', '" . $b . "', '" . $time . "')";
$temp2 = sql_query($temp);
//as a result mysql query with query INSERT returns true or false
if ($temp2) {
return true;
} else {
return false;
}
}
示例10: comment_write_to_db
function comment_write_to_db($a, $b, $c)
{
sql_connect();
// geting string from entered by user post where \n is marked with full stop '.'
$post_arr = comment_to_array($c);
//$time = date('H:i:s', time()) . ' : ' .date('d-m-Y');// БД ставит автоматически там TIMESTAMP
$temp = "INSERT INTO comments_articles (article_name, article_comment_title, article_comment_content) " . "VALUES ('" . $a . "', '" . $b . "', '" . $post_arr . "')";
$temp2 = sql_query($temp);
//as a result mysql query with query INSERT returns true or false
if ($temp2) {
return true;
} else {
return false;
}
}
示例11: Mysql_Connexion
function Mysql_Connexion()
{
$ret_p = sql_connect();
if (!$ret_p) {
$Titlesitename = "NPDS";
if (file_exists("meta/meta.php")) {
include "meta/meta.php";
}
if (file_exists("static/database.txt")) {
include "static/database.txt";
}
die;
}
return $ret_p;
}
示例12: initSoapFunction
function initSoapFunction()
{
global $opt, $db;
// init faults
if (($opt['debug'] & DEBUG_OUTOFSERVICE) == DEBUG_OUTOFSERVICE) {
return new nusoap_fault(WS_ERR_OUTOFSERVICE_ID, '', WS_ERR_OUTOFSERVICE_STR);
}
if ($opt['page']['nusoap_require_https'] == true) {
if (!isset($_REQUEST['HTTPS'])) {
return new nusoap_fault(WS_ERR_REQUIRE_HTTPS_ID, '', WS_ERR_REQUIRE_HTTPS_STR);
}
}
if ($db['dblink'] == false) {
// try connect
sql_connect(null, null, false);
if ($db['dblink'] == false) {
return new nusoap_fault(WS_ERR_DATABASE_CONNECT_ID, '', WS_ERR_DATABASE_CONNECT_STR);
}
}
return false;
}
示例13: sql_query
/**
* 执行一行代码(无结果集)
* @param $sql
*/
function sql_query($sql)
{
$link = get_connect();
$r = $link->query($sql);
if ($r == false) {
$errno = mysqli_connect_errno();
if ($errno == 2006) {
// mysql has gone away, 重新连接一下
sql_connect();
$r = $link->query($sql);
if ($r == false) {
$GLOBALS['connection'] = null;
throw new Exception(mysqli_connect_errno . ": " . $errno);
}
} else {
$GLOBALS['connection'] = null;
throw new Exception(mysqli_connect_errno . ": " . $errno);
}
}
return $r;
}
示例14: g4_get_member
/**
* simplified common.php by wkpark @ gmail.com
* since 2015/04/29
*/
function g4_get_member()
{
global $g4, $g5, $g4_root_dir;
// init
$member = array();
if (!defined('G5_VERSION')) {
include_once "{$g4_root_dir}/lib/constant.php";
// constants
}
include_once "{$g4_root_dir}/lib/common.lib.php";
// common library
if (defined('G5_VERSION')) {
include_once "{$g4_root_dir}/data/dbconfig.php";
// db configs
} else {
include_once "{$g4_root_dir}/dbconfig.php";
// db configs
}
if (defined('G5_VERSION')) {
$connect_db = sql_connect(G5_MYSQL_HOST, G5_MYSQL_USER, G5_MYSQL_PASSWORD);
$select_db = sql_select_db(G5_MYSQL_DB, $connect_db);
$g5['connect_db'] = $connect_db;
sql_query(" set names utf8 ");
} else {
$connect_db = sql_connect($mysql_host, $mysql_user, $mysql_password);
$select_db = sql_select_db($mysql_db, $connect_db);
}
// is it a valid PHPSESSID ?
if ($_REQUEST['PHPSESSID'] && $_REQUEST['PHPSESSID'] != session_id()) {
$member['mb_id'] = '';
return $member;
}
// already logged in
if (!empty($_SESSION['ss_mb_id'])) {
$member = get_member($_SESSION['ss_mb_id']);
}
return $member;
}
示例15: _saveresult
function _saveresult($vlocid, $vlocactive, $vlocname, $vloccity, $vlocplz, $vlocaddress, $vlocphone, $vlocemail, $vlocrealm, $vlcoordinates)
{
#TODO v5 change to ORM class
global $dbhost, $dbuname, $dbpass, $dbname;
if (strlen($vlocid) > 5 && !is_numeric($vlid)) {
return 0;
}
$ad = getdate(time());
$vfcre_info = $ad[year] . "-" . $ad[mon] . "-" . $ad[mday];
if (strlen($vlocname) == 0) {
die("0");
}
if (!ereg("([0-9]{1})", $vlocrealm)) {
die("0");
}
$vlocname = strip_tags($vlocname);
$vloccity = strip_tags($vloccity);
$vlocplz = strip_tags($vlocplz);
$vlocaddress = strip_tags($vlocaddress);
$vlocphone = strip_tags($vlocphone);
$vlocemail = strip_tags($vlocemail);
$vlcoordinates = strip_tags($vlcoordinates);
if (!ereg("([0-1]{1})", $vlocactive)) {
$vlocactive = 1;
}
if ($vlocid > 0) {
$qry = "update tbllocation set lname=\"{$vlocname}\", lcity=\"{$vloccity}\", lplz=\"{$vlocplz}\", laddress=\"{$vlocaddress}\", lphone=\"{$vlocphone}\",lactive={$vlocactive}, lrealm_id={$vlocrealm},lemail=\"{$vlocemail}\",lcoordinates=\"{$vlcoordinates}\" where id={$vlocid}";
} else {
$qry = "insert into tbllocation(id,lname,lcity,lplz,laddress,lphone,lactive,lrealm_id,lemail,lcoordinates) values(0,\"{$vlocname}\",\"{$vloccity}\",\"{$vlocplz}\",\"{$vlocaddress}\",\"{$vlocphone}\",{$vlocactive},{$vlocrealm},\"{$vlocemail}\",\"{$vlcoordinates}\")";
}
$dbi = sql_connect($dbhost, $dbuname, $dbpass, $dbname);
$presult = sql_query("insert into tdsolog values(0,1,'fsaveLocation','{$vfcre_info}','EX: {$qry}')", $dbi);
echo $qry;
$presult = sql_query($qry, $dbi);
//sleep(1);
echo $presult;
}