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


PHP mysql_die函数代码示例

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


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

示例1: get_table_content

 function get_table_content($db, $table, $handler)
 {
     $result = mysql_db_query($db, "SELECT * FROM {$table}") or mysql_die();
     $i = 0;
     while ($row = mysql_fetch_row($result)) {
         $table_list = "(";
         for ($j = 0; $j < mysql_num_fields($result); $j++) {
             $table_list .= mysql_field_name($result, $j) . ",";
         }
         $table_list = substr($table_list, 0, -2);
         $table_list .= ")";
         if (isset($GLOBALS["showcolumns"])) {
             $schema_insert = "INSERT INTO {$table} {$table_list} VALUES (";
         } else {
             $schema_insert = "INSERT INTO {$table} VALUES (";
         }
         for ($j = 0; $j < mysql_num_fields($result); $j++) {
             if (!isset($row[$j])) {
                 $schema_insert .= " NULL,";
             } elseif ($row[$j] != "") {
                 $schema_insert .= " '" . addslashes($row[$j]) . "',";
             } else {
                 $schema_insert .= " '',";
             }
         }
         $schema_insert = ereg_replace(",\$", "", $schema_insert);
         $schema_insert .= ")";
         $handler(trim($schema_insert));
         $i++;
     }
     return true;
 }
开发者ID:philum,项目名称:cms,代码行数:32,代码来源:dump.php

示例2: SyncDBContent

 function SyncDBContent($db_host = "", $db_name = "", $db_user = "", $db_user = "")
 {
     $this->db_name = $db_name;
     $this->db_link = @mysql_connect($db_host, $db_user, $db_pass) or mysql_die();
     mysql_select_db($this->db_name) or mysql_die();
     $this->db_tables = $this->get_tablenames();
 }
开发者ID:umahatokula,项目名称:academia,代码行数:7,代码来源:SyncDBContent.php

示例3: my_handler

/**
 * Insert datas from one table to another one
 *
 * @param   string  the original insert statement
 *
 * @global  string  the database name
 * @global  string  the original table name
 * @global  string  the target database and table names
 * @global  string  the sql query used to copy the data
 */
function my_handler($sql_insert = '')
{
    global $db, $table, $target;
    global $sql_insert_data;
    $sql_insert = eregi_replace('INSERT INTO (`?)' . $table . '(`?)', 'INSERT INTO ' . $target, $sql_insert);
    $result = mysql_query($sql_insert) or mysql_die('', $sql_insert);
    $sql_insert_data .= $sql_insert . ';' . "\n";
}
开发者ID:CMMCO,项目名称:Intranet,代码行数:18,代码来源:tbl_copy.php

示例4: mysql_die

 if (!empty($lastname_per)) {
     // Look if contact is in table
     $columns = "*";
     $tables = "contact";
     $where = "conid='{$id}'";
     if (!$db->query("SELECT {$columns} FROM {$tables} WHERE {$where}")) {
         mysql_die($db);
     } else {
         // If contact in table
         if ($db->next_record()) {
             if ($db->f("user") == $auth->auth["uname"] || $perm->have_perm("admin")) {
                 // Insert new contact person
                 $tables = "persons";
                 $set = "conid_per='{$id}',salutation_per='{$salutation_per}',firstname_per='{$firstname_per}',lastname_per='{$lastname_per}',grad_per='{$grad_per}',position_per='{$position_per}',phone_per='{$phone_per}',fax_per='{$fax_per}',email_per='{$email_per}',homepage_per='{$homepage_per}',comment_per='{$comment_per}',status_per='A',modification_per=NOW(),creation_per=NOW()";
                 if (!$db->query("INSERT {$tables} SET {$set}")) {
                     mysql_die($db);
                 }
                 // Select and show new/updated contact with contact persons
                 conbyconid($db, $id);
                 perbyconid($db, $id);
                 if ($ml_notify) {
                     $msg = "insert contact person \"{$firstname_per} {$lastname_per}\" of contact (ID: {$id}) by " . $auth->auth["uname"] . ".";
                     mailuser("admin", "insert contact person", $msg);
                 }
             } else {
                 $be->box_full($t->translate("Error"), $t->translate("Access denied"));
             }
             // If contact is not in table
         } else {
             $be->box_full($t->translate("Error"), $t->translate("Contact") . " (ID: {$id}) " . $t->translate("does not exist") . ".");
         }
开发者ID:BackupTheBerlios,项目名称:sourcecontact,代码行数:31,代码来源:perins.php

示例5: mysql_die

<?php

/* $Id: tbl_select.php,v 1.17 2001/08/29 12:00:07 loic1 Exp $ */
/**
 * Gets some core libraries
 */
require './grab_globals.inc.php';
require './lib.inc.php';
/**
 * Not selection yet required -> displays the selection form
 */
if (!isset($param) || $param[0] == '') {
    include './header.inc.php';
    $result = @mysql_list_fields($db, $table);
    if (!$result) {
        mysql_die('', 'mysql_list_fields(' . $db . ', ' . $table . ')');
    } else {
        // Gets the list and number of fields
        $fields_count = mysql_num_fields($result);
        for ($i = 0; $i < $fields_count; $i++) {
            $fields_list[] = mysql_field_name($result, $i);
            $fields_type[] = mysql_field_type($result, $i);
            $fields_len[] = mysql_field_len($result, $i);
        }
        ?>
<form method="post" action="tbl_select.php">
    <input type="hidden" name="server" value="<?php 
        echo $server;
        ?>
" />
    <input type="hidden" name="lang" value="<?php 
开发者ID:CMMCO,项目名称:Intranet,代码行数:31,代码来源:tbl_select.php

示例6: backquote

            $sql_query .= "\n" . 'ALTER TABLE ' . backquote($db) . '.' . backquote($table) . ' ADD INDEX (' . $index . ')';
            $result = mysql_query('ALTER TABLE ' . backquote($db) . '.' . backquote($table) . ' ADD INDEX (' . $index . ')') or mysql_die();
        }
    }
    // end if
    // Builds the uniques statements and updates the table
    $unique = '';
    if (isset($field_unique)) {
        for ($i = 0; $i < count($field_unique); $i++) {
            $j = $field_unique[$i];
            $unique .= backquote($field_name[$j]) . ', ';
        }
        // end for
        $unique = ereg_replace(', $', '', $unique);
        if (!empty($unique)) {
            $sql_query .= "\n" . 'ALTER TABLE ' . backquote($db) . '.' . backquote($table) . ' ADD UNIQUE (' . $unique . ')';
            $result = mysql_query('ALTER TABLE ' . backquote($db) . '.' . backquote($table) . ' ADD UNIQUE (' . $unique . ')') or mysql_die();
        }
    }
    // end if
    // Go back to table properties
    $message = $strTable . ' ' . htmlspecialchars($table) . ' ' . $strHasBeenAltered;
    include './tbl_properties.php';
    exit;
} else {
    $action = 'tbl_addfield.php';
    include './tbl_properties.inc.php';
    // Diplays the footer
    echo "\n";
    include './footer.inc.php';
}
开发者ID:CMMCO,项目名称:Intranet,代码行数:31,代码来源:tbl_addfield.php

示例7: dbn

function dbn($string)
{
    global $database_link;
    mysql_query($string, $database_link) or mysql_die($string);
}
开发者ID:nilsine,项目名称:Astra-Vires,代码行数:5,代码来源:common.inc.php

示例8: GetRowByQuery

/** Runs '$query' and returns the first (arbitrarily) found row.
 */
function GetRowByQuery($query)
{
    $QueryResult = mysql_query($query) or mysql_die($query);
    $Result = mysql_fetch_array($QueryResult);
    return $Result;
}
开发者ID:EQMacEmu,项目名称:allaclone,代码行数:8,代码来源:mysql.php

示例9: sql_addslashes

    // Adds table type (2 May 2001 - Robbat2)
    if (!empty($tbl_type) && $tbl_type != 'Default') {
        $sql_query .= ' TYPE = ' . $tbl_type;
    }
    if (MYSQL_INT_VERSION >= 32300 && !empty($comment)) {
        $sql_query .= ' comment = \'' . sql_addslashes($comment) . '\'';
    }
    // Executes the query
    $result = mysql_query($sql_query) or mysql_die();
    $message = $strTable . ' ' . htmlspecialchars($table) . ' ' . $strHasBeenCreated;
    include './tbl_properties.php';
    exit;
} else {
    if (isset($num_fields)) {
        $num_fields = intval($num_fields);
    }
    // No table name
    if (!isset($table) || trim($table) == '') {
        mysql_die($strTableEmpty);
    } else {
        if (empty($num_fields) || !is_int($num_fields)) {
            mysql_die($strFieldsEmpty);
        } else {
            $action = 'tbl_create.php';
            include './tbl_properties.inc.php';
            // Diplays the footer
            echo "\n";
            include './footer.inc.php';
        }
    }
}
开发者ID:CMMCO,项目名称:Intranet,代码行数:31,代码来源:tbl_create.php

示例10: get_table_def

 function get_table_def($db, $table, $crlf)
 {
     $schema_create = "";
     //$schema_create .= "DROP TABLE IF EXISTS $table;$crlf";
     $schema_create .= "CREATE TABLE {$table} ({$crlf}";
     $result = mysql_db_query($db, "SHOW FIELDS FROM {$table}") or mysql_die();
     while ($row = mysqli_fetch_array($result)) {
         $schema_create .= "   {$row['Field']} {$row['Type']}";
         if (isset($row["Default"]) && (!empty($row["Default"]) || $row["Default"] == "0")) {
             $schema_create .= " DEFAULT '{$row['Default']}'";
         }
         if ($row["Null"] != "YES") {
             $schema_create .= " NOT NULL";
         }
         if ($row["Extra"] != "") {
             $schema_create .= " {$row['Extra']}";
         }
         $schema_create .= ",{$crlf}";
     }
     $schema_create = ereg_replace("," . $crlf . "\$", "", $schema_create);
     $result = mysql_db_query($db, "SHOW KEYS FROM {$table}") or mysql_die();
     while ($row = mysqli_fetch_array($result)) {
         $kname = $row['Key_name'];
         if ($kname != "PRIMARY" && $row['Non_unique'] == 0) {
             $kname = "UNIQUE|{$kname}";
         }
         if (!isset($index[$kname])) {
             $index[$kname] = array();
         }
         $index[$kname][] = $row['Column_name'];
     }
     while (list($x, $columns) = @each($index)) {
         $schema_create .= ",{$crlf}";
         if ($x == "PRIMARY") {
             $schema_create .= "   PRIMARY KEY (" . implode($columns, ", ") . ")";
         } elseif (substr($x, 0, 6) == "UNIQUE") {
             $schema_create .= "   UNIQUE " . substr($x, 7) . " (" . implode($columns, ", ") . ")";
         } else {
             $schema_create .= "   KEY {$x} (" . implode($columns, ", ") . ")";
         }
     }
     $schema_create .= "{$crlf})";
     return stripslashes($schema_create);
 }
开发者ID:rotvulpix,项目名称:php-nuke,代码行数:44,代码来源:backup.php

示例11: showRelated

 function showRelated($foreign_table = false, $opts = false)
 {
     if (is_array($opts)) {
         extract($opts);
     }
     if ($foreign_table) {
         $sql = " SELECT * FROM {$foreign_table} WHERE {$this->_indexField} = {$this->id} ";
         $result = mysql_db_query($this->_db, $sql) or mysql_die($sql);
         if ($debug) {
             echo "<hr><pre> {$sql} </pre><hr>";
         }
         if ($get_result) {
             return $result;
         }
         // It would be nice to use the object here, and be able to customize with the $this->summary_link function.
         if (class_exists($foreign_table)) {
             while ($row = mysql_fetch_array($result)) {
                 $object = new $table($row[0]);
                 $object->summary_link();
             }
         } else {
             // get the title field
             $sql = "";
         }
     }
 }
开发者ID:jonah,项目名称:ActiveCoreDBOS,代码行数:26,代码来源:DBOS.class.php

示例12: exists

 public function exists($id = '')
 {
     $idf = $this->_idField;
     if ($id === '') {
         $id = $this->getId();
     }
     // bail if a lookup would obviously fail
     if (!$this->hasId()) {
         return false;
     }
     $sql = "SELECT `{$this->_idField}` FROM `{$this->_table}` WHERE `{$this->_idField}` = '{$id}'";
     $foundit = false;
     if ($res = mysql_db_query($this->_db, $sql) or mysql_die($sql)) {
         if (mysql_num_rows($res) == 1) {
             $found_id = mysql_result($res, 0, 0);
             if ($found_id == $id) {
                 $foundit = true;
             }
         }
         mysql_free_result($res);
     }
     return $foundit;
 }
开发者ID:jonah,项目名称:ActiveCoreDBOS,代码行数:23,代码来源:DBObjectAC.class.php

示例13: array

 if ($num_dbs) {
     $true_dblist = array();
     for ($i = 0; $i < $num_dbs; $i++) {
         $dblink = @mysql_select_db($dblist[$i]);
         if ($dblink) {
             $true_dblist[] = $dblist[$i];
         }
         // end if
     }
     // end for
     unset($dblist);
     $dblist = $true_dblist;
     unset($true_dblist);
     $num_dbs = count($dblist);
 } else {
     $dbs = mysql_list_dbs() or mysql_die('', 'mysql_list_dbs()', FALSE, FALSE);
     $num_dbs = @mysql_num_rows($dbs);
     $real_num_dbs = 0;
     for ($i = 0; $i < $num_dbs; $i++) {
         $db_name_tmp = mysql_dbname($dbs, $i);
         //echo $db_name_tmp."<br>";
         if ($db_name_tmp != "test") {
             $dblink = @mysql_select_db($db_name_tmp);
             if ($dblink) {
                 $dblist[] = $db_name_tmp;
                 $real_num_dbs++;
             }
         }
     }
     // end for
     $num_dbs = $real_num_dbs;
开发者ID:CMMCO,项目名称:Intranet,代码行数:31,代码来源:left.php

示例14: get_table_content

function get_table_content($src_table, $dest_table, $crlf, $escape, &$stream = null)
{
    $out = '';
    $table_list = '';
    $result = mysql_query("SELECT * FROM {$src_table}") or mysql_die();
    $i = 0;
    $block_size = 100;
    while ($row = mysql_fetch_row($result)) {
        if (empty($table_list)) {
            $table_list = "(";
            for ($j = 0; $j < mysql_num_fields($result); $j++) {
                $table_list .= $escape . mysql_field_name($result, $j) . $escape . ", ";
            }
            $table_list = substr($table_list, 0, -2);
            $table_list .= ")";
        }
        if ($i % $block_size == 0) {
            $schema_insert = ';' . $crlf . 'INSERT INTO ' . $escape . $dest_table . $escape . ' ' . $table_list . ' VALUES' . $crlf . '(';
        } else {
            $schema_insert = ",{$crlf}(";
        }
        for ($j = 0; $j < mysql_num_fields($result); $j++) {
            if (!isset($row[$j])) {
                $schema_insert .= " NULL,";
            } elseif ($row[$j] != "") {
                $schema_insert .= " '" . mysql_real_escape_string($row[$j]) . "',";
            } else {
                $schema_insert .= " '',";
            }
        }
        $schema_insert = ereg_replace(",\$", "", $schema_insert);
        $schema_insert .= ")";
        if (!empty($stream)) {
            fputs($stream, $schema_insert);
        } else {
            $out .= $schema_insert;
        }
        $i++;
    }
    if (!empty($stream)) {
        return true;
    }
    return $out . ';' . $crlf;
}
开发者ID:albinguillaume,项目名称:testMO,代码行数:44,代码来源:library.inc.php

示例15: get_table_csv

 /**
  * Outputs the content of a table in CSV format
  *
  * Last revision 14 July 2001: Patch for limiting dump size from
  * vinay@sanisoft.com & girish@sanisoft.com
  *
  * @param   string   the database name
  * @param   string   the table name
  * @param   integer  the offset on this table
  * @param   integer  the last row to get
  * @param   string   the field separator character
  * @param   string   the optionnal "enclosed by" character
  * @param   string   the handler (function) to call. It must accept one
  *                   parameter ($sql_insert)
  *
  * @global  string   whether to obtain an excel compatible csv format or a
  *                   simple csv one
  *
  * @return  boolean always true
  */
 function get_table_csv($db, $table, $limit_from = 0, $limit_to = 0, $sep, $enc_by, $esc_by, $handler)
 {
     global $what;
     // Handles the "separator" and the optionnal "enclosed by" characters
     if (empty($sep) || $what == 'excel') {
         $sep = ';';
     } else {
         if (get_magic_quotes_gpc()) {
             $sep = stripslashes($sep);
         }
         $sep = str_replace('\\t', "\t", $sep);
     }
     if (empty($enc_by) || $what == 'excel') {
         $enc_by = '"';
     } else {
         if (get_magic_quotes_gpc()) {
             $enc_by = stripslashes($enc_by);
         }
         $enc_by = str_replace('&quot;', '"', $enc_by);
     }
     if (empty($esc_by) || $what == 'excel') {
         // double the "enclosed by" character
         $esc_by = $enc_by;
     } else {
         if (get_magic_quotes_gpc()) {
             $esc_by = stripslashes($esc_by);
         }
     }
     // Defines the offsets to use
     if ($limit_from > 0) {
         $limit_from--;
     } else {
         $limit_from = 0;
     }
     if ($limit_to > 0 && $limit_from >= 0) {
         $add_query = " LIMIT {$limit_from}, {$limit_to}";
     } else {
         $add_query = '';
     }
     // Gets the data from the database
     $local_query = 'SELECT * FROM ' . backquote($db) . '.' . backquote($table) . $add_query;
     $result = mysql_query($local_query) or mysql_die('', $local_query);
     // Format the data
     $i = 0;
     while ($row = mysql_fetch_row($result)) {
         @set_time_limit(60);
         $schema_insert = '';
         $fields_cnt = mysql_num_fields($result);
         for ($j = 0; $j < $fields_cnt; $j++) {
             if (!isset($row[$j])) {
                 $schema_insert .= 'NULL';
             } else {
                 if ($row[$j] != '') {
                     // loic1 : always enclose fields
                     if ($what == 'excel') {
                         $row[$j] = ereg_replace("\r(\n)?", "\n", $row[$j]);
                     }
                     $schema_insert .= $enc_by . str_replace($enc_by, $esc_by . $enc_by, $row[$j]) . $enc_by;
                 } else {
                     $schema_insert .= '';
                 }
             }
             if ($j < $fields_cnt - 1) {
                 $schema_insert .= $sep;
             }
         }
         // end for
         $handler(trim($schema_insert));
         ++$i;
     }
     // end while
     return TRUE;
 }
开发者ID:CMMCO,项目名称:Intranet,代码行数:93,代码来源:lib.inc.php


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