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


PHP sql_error函数代码示例

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


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

示例1: __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
 }
开发者ID:drognisep,项目名称:Simple-Groupware,代码行数:28,代码来源:cms.php

示例2: exec_base_delete_all_dist

/**
 * Exec de la page de destruction des tables de SPIP
**/
function exec_base_delete_all_dist()
{
    include_spip('inc/autoriser');
    if (!autoriser('detruire')) {
        include_spip('inc/minipres');
        echo minipres();
    } else {
        include_spip('base/dump');
        $res = base_lister_toutes_tables('', array(), array(), true);
        if (!$res) {
            include_spip('inc/minipres');
            spip_log("Erreur base de donnees");
            echo minipres(_T('info_travaux_titre'), _T('titre_probleme_technique') . "<p><tt>" . sql_errno() . " " . sql_error() . "</tt></p>");
        } else {
            $res = base_saisie_tables('delete', $res);
            include_spip('inc/headers');
            $res = "\n<ol style='text-align:left'><li>\n" . join("</li>\n<li>", $res) . '</li></ol>';
            $admin = charger_fonction('admin', 'inc');
            $res = $admin('delete_all', _T('titre_page_delete_all'), $res);
            if (!$res) {
                redirige_url_ecrire('install', '');
            } else {
                echo $res;
            }
        }
    }
}
开发者ID:JLuc,项目名称:SPIP,代码行数:30,代码来源:base_delete_all.php

示例3: bb2_db_query

function bb2_db_query($query)
{
    $result = sql_query($query);
    if (sql_error()) {
        return FALSE;
    }
    return $result;
}
开发者ID:NucleusCMS,项目名称:NP_BadBehavior,代码行数:8,代码来源:bad-behavior-nucleuscms.php

示例4: db_connect

function db_connect()
{
    $link_id = mysql_connect($dbhost, $dbusername, $dbuserpassword);
    if (!$link_id) {
        die("Conexão falhou ao host {$dbhost} base {$default_dbname}.<br>" . sql_error($link_id));
    } else {
        mysql_select_db($dbname, $link_id);
    }
    return $link_id;
}
开发者ID:TecwebSI,项目名称:Tecweb-teste,代码行数:10,代码来源:conexao.php

示例5: get_cip_id

 function get_cip_id()
 {
     $query = "select cip_id from " . TABLE_CIP . " where cip_folder_name='" . $this->contrib . "' ";
     $result = cip_db_query($query);
     if ($result === false) {
         $this->error(sql_error($query));
     } else {
         $installed = vam_db_fetch_array($result);
         return $installed['cip_id'];
     }
 }
开发者ID:nomadcomanche,项目名称:zdorov_shop,代码行数:11,代码来源:ci_tag.class.php

示例6: base_repair_dist

/**
 * Action de réparation de la base de données
 *
 * Tente de réparer les tables, recalcule les héritages et secteurs
 * de rubriques. Affiche les erreurs s'il y en a eu.
 *
 * @pipeline_appel base_admin_repair
 * @uses admin_repair_tables()
 * @uses calculer_rubriques()
 * @uses propager_les_secteurs()
 *
 * @param string $titre Inutilisé
 * @param string $reprise Inutilisé
 **/
function base_repair_dist($titre = '', $reprise = '')
{
    $res = admin_repair_tables();
    if (!$res) {
        $res = "<div class='error'>" . _T('avis_erreur_mysql') . ' ' . sql_errno() . ': ' . sql_error() . "</div>\n";
    } else {
        include_spip('inc/rubriques');
        calculer_rubriques();
        propager_les_secteurs();
    }
    include_spip('inc/minipres');
    $res .= pipeline('base_admin_repair', $res);
    echo minipres(_T('texte_tentative_recuperation'), $res . generer_form_ecrire('accueil', '', '', _T('public:accueil_site')));
}
开发者ID:xablen,项目名称:Semaine14_SPIP_test,代码行数:28,代码来源:repair.php

示例7: db_connect

function db_connect($dbname)
{
    global $dbhost, $dbusername, $dbuserpassword, $default_dbname;
    global $MYSQL_ERRNO, $MYSQL_ERROR;
    $link_id = mysql_connect($dbhost, $dbusername, $dbuserpassword);
    if (!$link_id) {
        die("Conexão falhou ao host {$dbhost} base {$default_dbname}.<br>");
    } elseif (empty($dbname)) {
        if (!mysql_select_db($default_dbname, $link_id)) {
            die(sql_error($link_id));
        }
    } elseif (!mysql_select_db($dbname, $link_id)) {
        die(sql_error($link_id));
    }
    return $link_id;
}
开发者ID:TecwebSI,项目名称:tecweb-master,代码行数:16,代码来源:salvar.php

示例8: save_config

function save_config($config, $holder, $redirect, $save_blocks = true)
{
    global $form, $lang_system, $lang_admin;
    if ($save_blocks) {
        $form['blocks'] = $_POST['blocks'] ? count($_POST['blocks']) == $_POST['blocks_count'] ? '' : implode(', ', $_POST['blocks']) : 'NULL';
    }
    foreach ($form as $key => $value) {
        if (isset($config[$key]) && $config[$key] != $value) {
            $value ? sql_query('
					UPDATE ' . DB_PREFIX . 'config
					SET content = ' . (is_numeric($value) ? $value : '"' . $value . '"') . '
					WHERE name = "' . $key . '" AND holder = "' . $holder . '"') : sql_query('DELETE FROM ' . DB_PREFIX . 'config WHERE name = "' . $key . '" AND holder = "' . $holder . '"');
        } elseif (!isset($config[$key]) && $value) {
            sql_query('
				INSERT INTO ' . DB_PREFIX . 'config (holder, name, content)
				VALUES ("' . $holder . '", "' . $key . '", ' . (is_numeric($value) ? (int) $value : '"' . $value . '"') . ')');
        }
    }
    sql_error() ? negative(array($lang_system['ERROR_SQL'], sql_error())) : positive($lang_admin['SAVED_SUCCESSFUL']) . redirect($redirect);
}
开发者ID:rafalenden,项目名称:KioCMS,代码行数:20,代码来源:includes.php

示例9: mrbsCheckFree

/** mrbsCheckFree()
 * 
 * Check to see if the time period specified is free
 * 
 * $room_id   - Which room are we checking
 * $starttime - The start of period
 * $endtime   - The end of the period
 * $ignore    - An entry ID to ignore, 0 to ignore no entries
 * $repignore - A repeat ID to ignore everything in the series, 0 to ignore no series
 * 
 * Returns:
 *   nothing   - The area is free
 *   something - An error occured, the return value is human readable
 */
function mrbsCheckFree($room_id, $starttime, $endtime, $ignore, $repignore)
{
    global $tbl_entry;
    global $enable_periods;
    global $periods;
    # Select any meetings which overlap ($starttime,$endtime) for this room:
    $sql = "SELECT id, name, start_time FROM {$tbl_entry} WHERE\n\t\tstart_time < {$endtime} AND end_time > {$starttime}\n\t\tAND room_id = {$room_id}";
    if ($ignore > 0) {
        $sql .= " AND id <> {$ignore}";
    }
    if ($repignore > 0) {
        $sql .= " AND repeat_id <> {$repignore}";
    }
    $sql .= " ORDER BY start_time";
    $res = sql_query($sql);
    if (!$res) {
        return sql_error();
    }
    if (sql_count($res) == 0) {
        sql_free($res);
        return "";
    }
    # Get the room's area ID for linking to day, week, and month views:
    $area = mrbsGetRoomArea($room_id);
    # Build a string listing all the conflicts:
    $err = "";
    for ($i = 0; $row = sql_row($res, $i); $i++) {
        $starts = getdate($row[2]);
        $param_ym = "area={$area}&year={$starts['year']}&month={$starts['mon']}";
        $param_ymd = $param_ym . "&day={$starts['mday']}";
        if ($enable_periods) {
            $p_num = $starts['minutes'];
            $startstr = userdate($row[2], '%A %d %B %Y, ') . $periods[$p_num];
        } else {
            $startstr = userdate($row[2], '%A %d %B %Y %H:%M:%S');
        }
        $err .= "<LI><A HREF=\"view_entry.php?id={$row['0']}\">{$row['1']}</A>" . " ( " . $startstr . ") " . "(<A HREF=\"day.php?{$param_ymd}\">" . get_string('viewday', 'block_mrbs') . "</a>" . " | <A HREF=\"week.php?room={$room_id}&{$param_ymd}\">" . get_string('viewweek', 'block_mrbs') . "</a>" . " | <A HREF=\"month.php?room={$room_id}&{$param_ym}\">" . get_string('viewmonth', 'block_mrbs') . "</a>)";
    }
    return $err;
}
开发者ID:rtsfc,项目名称:moodle-block_mrbs,代码行数:54,代码来源:mrbs_sql.php

示例10: auth_echec

/**
 * fonction appliquee par ecrire/index sur le resultat de la precedente
 * en cas de refus de connexion.
 * Retourne un message a afficher ou redirige illico.
 *
 * @param  $raison
 * @return array|string
 */
function auth_echec($raison)
{
    include_spip('inc/minipres');
    include_spip('inc/headers');
    // pas authentifie. Pourquoi ?
    if (is_string($raison)) {
        // redirection vers une page d'authentification
        // on ne revient pas de cette fonction
        // sauf si pb de header
        $raison = redirige_formulaire($raison);
    } elseif (is_int($raison)) {
        // erreur SQL a afficher
        $raison = minipres(_T('info_travaux_titre'), _T('titre_probleme_technique') . "<p><tt>" . sql_errno() . " " . sql_error() . "</tt></p>");
    } elseif (@$raison['statut']) {
        // un simple visiteur n'a pas acces a l'espace prive
        spip_log("connexion refusee a " . @$raison['id_auteur']);
        $raison = minipres(_T('avis_erreur_connexion'), _T('avis_erreur_visiteur'));
    } else {
        // auteur en fin de droits ...
        $h = $raison['site'];
        $raison = minipres(_T('avis_erreur_connexion'), "<br /><br /><p>" . _T('texte_inc_auth_1', array('auth_login' => $raison['login'])) . " <a href='{$h}'>" . _T('texte_inc_auth_2') . "</a>" . _T('texte_inc_auth_3'));
    }
    return $raison;
}
开发者ID:loorenzooo,项目名称:aslfc,代码行数:32,代码来源:auth.php

示例11: base_admin_repair_dist

function base_admin_repair_dist($titre='', $reprise='') {

	$f = sql_repair('repair', NULL, true);
	if ($f) {
		$res = admin_repair_tables();
	} else {
		if ($titre)
		  spip_log("Pas d'instruction REPAIR dans ce serveur SQL");
		$res = '     ';
	}

	if (!$res) {
		$res = "<br /><br /><span style='color: red; font-weight: bold;'><tt>"._T('avis_erreur_mysql').' '.sql_errno().': '.sql_error() ."</tt></span><br /><br /><br />\n";
	} else {
		include_spip('inc/rubriques');
		calculer_rubriques();
		propager_les_secteurs();
	}
	include_spip('inc/minipres');
	$res .= pipeline('base_admin_repair',$res);
	$res .= admin_repair_plat();
	echo minipres(_T('texte_tentative_recuperation'),
			$res . generer_form_ecrire('accueil', '','',_T('public:accueil_site')));
}
开发者ID:rhertzog,项目名称:lcs,代码行数:24,代码来源:admin_repair.php

示例12: showAccessDenied

include "config.inc.php";
include "functions.inc";
include "{$dbsys}.inc";
include "mrbs_auth.inc";
if (!getAuthorised(2)) {
    showAccessDenied($day, $month, $year, $area);
    exit;
}
# This file is for adding new areas/rooms
# we need to do different things depending on if its a room
# or an area
if ($type == "area") {
    $area_name_q = slashes($name);
    $sql = "insert into {$tbl_area} (area_name) values ('{$area_name_q}')";
    if (sql_command($sql) < 0) {
        fatal_error(1, "<p>" . sql_error());
    }
    $area = sql_insert_id("{$tbl_area}", "id");
}
if ($type == "room") {
    $room_name_q = slashes($name);
    $description_q = slashes($description);
    if (empty($capacity)) {
        $capacity = 0;
    }
    $sql = "insert into {$tbl_room} (room_name, area_id, description, capacity)\n\t        values ('{$room_name_q}',{$area}, '{$description_q}',{$capacity})";
    if (sql_command($sql) < 0) {
        fatal_error(1, "<p>" . sql_error());
    }
}
header("Location: admin.php?area={$area}");
开发者ID:jwigal,项目名称:emcommdb,代码行数:31,代码来源:add.php

示例13: sql_connect_slave

function sql_connect_slave($id)
{
    global $opt, $db;
    if ($id == -1) {
        sql_connect_master_as_slave();
        return;
    }
    // the right slave is connected
    if ($db['dblink_slave'] !== false) {
        // TODO: disconnect if other slave is connected
        if ($db['slave_id'] != $id) {
            sql_error();
        }
        return;
    }
    $db['slave_id'] = $id;
    $slave = $opt['db']['slaves'][$id];
    // for display in SQL debugger
    $db['slave_server'] = $slave['server'];
    if ($opt['db']['pconnect'] == true) {
        $db['dblink_slave'] = @mysql_pconnect($slave['server'], $slave['username'], $slave['password']);
    } else {
        $db['dblink_slave'] = @mysql_connect($slave['server'], $slave['username'], $slave['password']);
    }
    if ($db['dblink_slave'] !== false) {
        if (mysql_select_db($opt['db']['placeholder']['db'], $db['dblink_slave']) == false) {
            sql_error();
        }
        mysql_query("SET NAMES '" . mysql_real_escape_string($opt['charset']['mysql'], $db['dblink_slave']) . "'", $db['dblink_slave']);
        // initialize temp tables on slave server
        $rs = sqlf_slave("SELECT `threadid`, `name` FROM `sys_temptables` WHERE `threadid`='&1'", mysql_thread_id($db['dblink_slave']));
        while ($r = sql_fetch_assoc($rs)) {
            sqlf_slave("DROP TEMPORARY TABLE IF EXISTS &tmpdb.`&1`", $r['name']);
        }
        sql_free_result($rs);
        sqlf_slave("DELETE FROM &db.`sys_temptables` WHERE `threadid`='&1'", mysql_thread_id($db['dblink_slave']));
    } else {
        sql_error();
    }
}
开发者ID:kirstenko,项目名称:oc-server3,代码行数:40,代码来源:db.inc.php

示例14: mysql_query

             $q['SETD'] = "UPDATE " . TB_KNOWLEDGE_CAT . " SET sort = sort+1 WHERE sort = '" . $_GET['setsort'] . "' ";
             $sql['SETD'] = mysql_query($q['SETD']) or sql_error("db-query", mysql_error());
             $db->closedb();
             $db->connectdb(DB_NAME, DB_USERNAME, DB_PASSWORD);
             $q['SETU'] = "UPDATE " . TB_KNOWLEDGE_CAT . " SET sort = '" . $_GET['setsort'] . "' WHERE id = '" . $_GET['id'] . "' ";
             $sql['SETU'] = mysql_query($q['SETU']) or sql_error("db-query", mysql_error());
             $db->closedb();
         }
         if ($_GET['move'] == "down") {
             $db->connectdb(DB_NAME, DB_USERNAME, DB_PASSWORD);
             $q['SETD'] = "UPDATE " . TB_KNOWLEDGE_CAT . " SET sort = sort-1 WHERE sort = '" . $_GET['setsort'] . "' ";
             $sql['SETD'] = mysql_query($q['SETD']) or sql_error("db-query", mysql_error());
             $db->closedb();
             $db->connectdb(DB_NAME, DB_USERNAME, DB_PASSWORD);
             $q['SETU'] = "UPDATE " . TB_KNOWLEDGE_CAT . " SET sort = '" . $_GET['setsort'] . "' WHERE id = '" . $_GET['id'] . "' ";
             $sql['SETU'] = mysql_query($q['SETU']) or sql_error("db-query", mysql_error());
             $db->closedb();
         }
         $ProcessOutput = "<BR><BR>";
         $ProcessOutput .= "<CENTER><A HREF=\"?name=admin&file=main\"><IMG SRC=\"images/icon/login-welcome.gif\" BORDER=\"0\"></A><BR><BR>";
         $ProcessOutput .= "<FONT COLOR=\"#336600\"><B>" . _ADMIN_KNOWLEDGE_MESSAGE_CAT_EDIT . "</B></FONT><BR><BR>";
         $ProcessOutput .= "<A HREF=\"?name=admin&file=knowledge_category\"><B>" . _ADMIN_KNOWLEDGE_MESSAGE_CAT_GOBACK . "</B></A>";
         $ProcessOutput .= "</CENTER>";
         $ProcessOutput .= "<BR><BR>";
     } else {
         //¡Ã³ÕäÁè¼èÒ¹
         $ProcessOutput = $PermissionFalse;
     }
     echo $ProcessOutput;
 } else {
     if ($op == "articlecat_edit") {
开发者ID:robocon,项目名称:iopr,代码行数:31,代码来源:knowledge_category.php

示例15: sql_select

/**
 * Effectue une requête de selection
 *
 * Fonction de selection (SELECT), retournant la ressource interrogeable par sql_fetch.
 *
 * @api
 * @see sql_fetch()      Pour boucler sur les resultats de cette fonction
 *
 * @param array|string $select
 *     Liste des champs a recuperer (Select)
 * @param array|string $from
 *     Tables a consulter (From)
 * @param array|string $where
 *     Conditions a remplir (Where)
 * @param array|string $groupby
 *     Critere de regroupement (Group by)
 * @param array|string $orderby
 *     Tableau de classement (Order By)
 * @param string $limit
 *     Critere de limite (Limit)
 * @param array $having
 *     Tableau des des post-conditions a remplir (Having)
 * @param string $serveur
 *     Le serveur sollicite (pour retrouver la connexion)
 * @param bool|string $option
 *     Peut avoir 3 valeurs :
 *
 *     - false -> ne pas l'exécuter mais la retourner,
 *     - continue -> ne pas echouer en cas de serveur sql indisponible,
 *     - true|array -> executer la requête.
 *     Le cas array est, pour une requete produite par le compilateur,
 *     un tableau donnnant le contexte afin d'indiquer le lieu de l'erreur au besoin
 *
 *
 * @return mixed
 *     Ressource SQL
 *
 *     - Ressource SQL pour sql_fetch, si la requete est correcte
 *     - false en cas d'erreur
 *     - Chaine contenant la requete avec $option=false
 *
 * Retourne false en cas d'erreur, apres l'avoir denoncee.
 * Les portages doivent retourner la requete elle-meme en cas d'erreur,
 * afin de disposer du texte brut.
 *
 **/
function sql_select($select = array(), $from = array(), $where = array(), $groupby = array(), $orderby = array(), $limit = '', $having = array(), $serveur = '', $option = true)
{
    $f = sql_serveur('select', $serveur, $option === 'continue' or $option === false);
    if (!is_string($f) or !$f) {
        return false;
    }
    $debug = (defined('_VAR_MODE') and _VAR_MODE == 'debug');
    if ($option !== false and !$debug) {
        $res = $f($select, $from, $where, $groupby, $orderby, $limit, $having, $serveur, is_array($option) ? true : $option);
    } else {
        $query = $f($select, $from, $where, $groupby, $orderby, $limit, $having, $serveur, false);
        if (!$option) {
            return $query;
        }
        // le debug, c'est pour ce qui a ete produit par le compilateur
        if (isset($GLOBALS['debug']['aucasou'])) {
            list($table, $id, ) = $GLOBALS['debug']['aucasou'];
            $nom = $GLOBALS['debug_objets']['courant'] . $id;
            $GLOBALS['debug_objets']['requete'][$nom] = $query;
        }
        $res = $f($select, $from, $where, $groupby, $orderby, $limit, $having, $serveur, true);
    }
    // en cas d'erreur
    if (!is_string($res)) {
        return $res;
    }
    // denoncer l'erreur SQL dans sa version brute
    spip_sql_erreur($serveur);
    // idem dans sa version squelette (prefixe des tables non substitue)
    $contexte_compil = sql_error_backtrace(true);
    erreur_squelette(array(sql_errno($serveur), sql_error($serveur), $res), $contexte_compil);
    return false;
}
开发者ID:xablen,项目名称:Semaine14_SPIP_test,代码行数:79,代码来源:abstract_sql.php


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