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


PHP mysql_error函数代码示例

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


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

示例1: dbkit_run_query_with_array

function dbkit_run_query_with_array($sql, $args)
{
    foreach ($args as &$arg) {
        if (is_array($arg)) {
            if (count($arg) == 0) {
                $arg = array(-1);
            }
            $parts = array();
            foreach ($arg as $part) {
                $parts[] = "'" . mysql_real_escape_string("{$part}") . "'";
            }
            $arg = "(" . implode(",", $parts) . ")";
        } else {
            $arg = "'" . mysql_real_escape_string("{$arg}") . "'";
        }
    }
    $sql = str_replace("?", "%s", $sql);
    array_unshift($args, $sql);
    $sql = call_user_func_array('sprintf', $args);
    dbkit_log_query($sql);
    $res = mysql_query($sql);
    if (!$res) {
        die("database query failed: " . mysql_error());
    }
    return $res;
}
开发者ID:andreyvit,项目名称:retester,代码行数:26,代码来源:dbkit.inc.php

示例2: createMainDataElement

function createMainDataElement($plan, $num, $dbConn)
{
    if ($plan['dato_principal_' . $num] != NULL) {
        $query_dato = sprintf("SELECT * FROM tipoDatosServicios WHERE id_tipoDato=%s", GetSQLValueString($plan['id_tipoDato_principal_' . $num], "int"));
        $dato = mysql_query($query_dato, $dbConn) or die(mysql_error());
        $row_dato = mysql_fetch_assoc($dato);
        $display = true;
        $label = "";
        if ($row_dato['tipo'] == "boolean") {
            if ($plan['dato_principal_' . $num] == "1") {
                $label = $row_dato['label'];
            } else {
                $display = false;
            }
        } else {
            if ($row_dato['display_label']) {
                $label = $plan['dato_principal_' . $num] . " " . $row_dato['label'];
            } else {
                $label = $plan['dato_principal_' . $num];
            }
        }
        if ($display) {
            echo "<div class='dato'>";
            echo "\t<li class='tipo_" . $plan['id_tipoDato_principal_' . $num] . "' value='" . $plan['dato_principal_' . $num] . "'>";
            echo $label;
            echo "\t</li>";
            echo "</div>";
        }
    }
    //if
}
开发者ID:designomx,项目名称:eligefacil,代码行数:31,代码来源:comparadorBackup.php

示例3: getEventbriteEvents

function getEventbriteEvents($eb_keywords, $eb_city, $eb_proximity)
{
    global $eb_app_key;
    $xml_url = "https://www.eventbrite.com/xml/event_search?...&within=50&within_unit=M&keywords=" . $eb_keywords . "&city=" . $eb_city . "&date=This+month&app_key=" . $eb_app_key;
    echo $xml_url . "<br />";
    $xml = simplexml_load_file($xml_url);
    $count = 0;
    // loop over events from eventbrite xml
    foreach ($xml->event as $event) {
        // add event if it doesn't already exist
        $event_query = mysql_query("SELECT * FROM events WHERE id_eventbrite={$event->id}") or die(mysql_error());
        if (mysql_num_rows($event_query) == 0) {
            echo $event_id . " ";
            // get event url
            foreach ($event->organizer as $organizer) {
                $event_organizer_url = $organizer->url;
            }
            // get event address
            foreach ($event->venue as $venue) {
                $event_venue_address = $venue->address;
                $event_venue_city = $venue->city;
                $event_venue_postal_code = $venue->postal_code;
            }
            // get event title
            $event_title = str_replace(array("\r\n", "\r", "\n"), ' ', $event->title);
            // add event to database
            mysql_query("INSERT INTO events (id_eventbrite, \n                                      title,\n                                      created, \n                                      organizer_name, \n                                      uri, \n                                      start_date, \n                                      end_date, \n                                      address\n                                      ) VALUES (\n                                      '{$event->id}',\n                                      '" . parseInput($event_title) . "',\n                                      '" . strtotime($event->created) . "',\n                                      '" . trim(parseInput($event->organizer->name)) . "',\n                                      '{$event_organizer_url}',\n                                      '" . strtotime($event->start_date) . "',\n                                      '" . strtotime($event->end_date) . "',\n                                      '{$event_venue_address}, {$event_venue_city}, {$event_venue_postal_code}'\n                                      )") or die(mysql_error());
        }
        $count++;
    }
}
开发者ID:nickhammond,项目名称:represent-map,代码行数:31,代码来源:events_get.php

示例4: drawPixels

 /**
  * Find pixels coords and draw these on the current image
  *
  * @param integer $image Number of the image (to be used with $this->height)
  * @return boolean Success
  **/
 function drawPixels($image)
 {
     $limit = 0;
     do {
         /** Select with limit */
         $result = mysql_query(sprintf($this->query, $image * $this->height, ($image + 1) * $this->height - 1) . ' LIMIT ' . $limit . ',' . $this->limit);
         if ($result === false) {
             return $this->raiseError('Query failed: ' . mysql_error());
         }
         $count = mysql_num_rows($result);
         while ($click = mysql_fetch_row($result)) {
             $x = (int) $click[0];
             $y = (int) ($click[1] - $image * $this->height);
             if ($x < 0 || $x >= $this->width) {
                 continue;
             }
             /** Apply a calculus for the step, with increases the speed of rendering : step = 3, then pixel is drawn at x = 2 (center of a 3x3 square) */
             $x -= $x % $this->step - $this->startStep;
             $y -= $y % $this->step - $this->startStep;
             /** Add 1 to the current color of this pixel (color which represents the sum of clicks on this pixel) */
             $color = imagecolorat($this->image, $x, $y) + 1;
             imagesetpixel($this->image, $x, $y, $color);
             $this->maxClicks = max($this->maxClicks, $color);
             if ($image === 0) {
                 /** Looking for the maximum height of click */
                 $this->maxY = max($y, $this->maxY);
             }
         }
         /** Free resultset */
         mysql_free_result($result);
         $limit += $this->limit;
     } while ($count === $this->limit);
     return true;
 }
开发者ID:rgamado,项目名称:book_code,代码行数:40,代码来源:HeatmapFromDatabase.class.php

示例5: connecttodb

function connecttodb($servername,$dbname,$dbuser,$dbpassword)
{
    $link=mysql_connect ("$servername","$dbuser","$dbpassword",TRUE);
    if(!$link){die("Could not connect to MySQL");}
    mysql_select_db("$dbname",$link) or die ("could not open db".mysql_error());
    return $link;
}
开发者ID:ravinderphp,项目名称:revitalise,代码行数:7,代码来源:update.php

示例6: find

 public function find()
 {
     $result = array();
     $where = 'where 1 = 1 ';
     foreach ($this->columns as $objCol => $dbCol) {
         if ($this->{$objCol}) {
             $where .= " and {$dbCol} = {$this->{$objCol}}";
             //only bug: here I " and {$objCol} = {$this->$objCol}"; but with former experience, I know that database handling is the place where bug fills. So I var_dump($sql) and find it.
         }
     }
     $sql = "select * from {$this->table} {$where}";
     //		var_dump($sql);
     DataConnection::getConnection();
     $rs = mysql_query($sql) or die(mysql_error());
     $row = mysql_fetch_array($rs);
     while ($row) {
         $o = clone $this;
         foreach ($o->columns as $objCol => $dbCol) {
             $o->{$objCol} = $row[$dbCol];
         }
         $result[] = $o;
         $row = mysql_fetch_array($rs);
     }
     return $result;
 }
开发者ID:QiTai,项目名称:MiniChaoge,代码行数:25,代码来源:Kijiji.php

示例7: query

 /**
  * execute query - show be regarded as private to insulate the rest of
  * the application from sql differences
  * @access private
  */
 function query($sql)
 {
     global $CONF;
     if (is_null($this->dblink)) {
         $this->_connect();
     }
     //been passed more parameters? do some smart replacement
     if (func_num_args() > 1) {
         //query contains ? placeholders, but it's possible the
         //replacement string have ? in too, so we replace them in
         //our sql with something more unique
         $q = md5(uniqid(rand(), true));
         $sql = str_replace('?', $q, $sql);
         $args = func_get_args();
         for ($i = 1; $i <= count($args); $i++) {
             $sql = preg_replace("/{$q}/", "'" . preg_quote(mysql_real_escape_string($args[$i])) . "'", $sql, 1);
         }
         //we shouldn't have any $q left, but it will help debugging if we change them back!
         $sql = str_replace($q, '?', $sql);
     }
     $this->dbresult = mysql_query($sql, $this->dblink);
     if (!$this->dbresult) {
         die("Query failure: " . mysql_error() . "<br />{$sql}");
     }
     return $this->dbresult;
 }
开发者ID:carriercomm,项目名称:pastebin,代码行数:31,代码来源:legacy.php

示例8: query

 public function query($sql)
 {
     if ($this->link) {
         $resource = mysql_query($sql, $this->link);
         if ($resource) {
             if (is_resource($resource)) {
                 $i = 0;
                 $data = array();
                 while ($result = mysql_fetch_assoc($resource)) {
                     $data[$i] = $result;
                     $i++;
                 }
                 mysql_free_result($resource);
                 $query = new \stdClass();
                 $query->row = isset($data[0]) ? $data[0] : array();
                 $query->rows = $data;
                 $query->num_rows = $i;
                 unset($data);
                 return $query;
             } else {
                 return true;
             }
         } else {
             $trace = debug_backtrace();
             trigger_error('Error: ' . mysql_error($this->link) . '<br />Error No: ' . mysql_errno($this->link) . '<br /> Error in: <b>' . $trace[1]['file'] . '</b> line <b>' . $trace[1]['line'] . '</b><br />' . $sql);
         }
     }
 }
开发者ID:honeynatividad,项目名称:mircatu,代码行数:28,代码来源:mysql.php

示例9: RetrieveRecordArray

 function RetrieveRecordArray($filter = null)
 {
     $dtoArray = array();
     $query = "SELECT SUBC.*, TIPC.sigla as siglaTipoContrato FROM subContrato SUBC JOIN tipoContrato TIPC ON SUBC.tipocontrato_id = TIPC.id WHERE removido = 0";
     if (!empty($filter)) {
         $query = $query . " AND " . $filter;
     }
     $recordSet = mysql_query($query, $this->mysqlConnection);
     if (!$recordSet && $this->showErrors) {
         print_r(mysql_error());
         echo '<br/><br/>';
     }
     $recordCount = mysql_num_rows($recordSet);
     if ($recordCount == 0) {
         return $dtoArray;
     }
     $index = 0;
     while ($record = mysql_fetch_array($recordSet)) {
         $dto = new SubContractDTO();
         $dto->id = $record['id'];
         $dto->codigoContrato = $record['contrato_id'];
         $dto->codigoTipoContrato = $record['tipoContrato_id'];
         $dto->siglaTipoContrato = $record['siglaTipoContrato'];
         $dtoArray[$index] = $dto;
         $index++;
     }
     mysql_free_result($recordSet);
     return $dtoArray;
 }
开发者ID:renatosans,项目名称:contratos,代码行数:29,代码来源:SubContractDAO.php

示例10: getWebmbyid

function getWebmbyid($id)
{
    global $link;
    $query = "SELECT * FROM twebm WHERE cId = {$id}";
    $result = $link->query($query) or die('Запрос не удался: ' . mysql_error());
    return mysqli_fetch_array($result, MYSQLI_ASSOC);
}
开发者ID:netforhack,项目名称:YobaTube,代码行数:7,代码来源:functions.php

示例11: send

function send($to, $sub, $msg)
{
    $con = mysql_connect("localhost", "root", "password");
    if (!$con) {
        echo mysql_error();
    }
}
开发者ID:mkrdip,项目名称:Online-Attendance-and-Student-Information-System,代码行数:7,代码来源:mail_compose.php

示例12: getInsert

function getInsert($param, $name, $score)
{
    $dbParams = get_object_vars($param);
    $mysql_host = $dbParams['mysql_host'];
    $mysql_user = $dbParams['mysql_user'];
    $mysql_pass = $dbParams['mysql_pass'];
    $dbName = $dbParams['dbName'];
    $dbTable = $dbParams['dbTable'];
    //connect
    $link = mysql_connect($mysql_host, $mysql_user, $mysql_pass) or die('connection error: ' . mysql_error());
    //select db
    mysql_select_db($dbName) or die('DB error');
    //check user highest score
    $query_check_user = 'SELECT score FROM ' . $dbTable . ' WHERE name = ' . $name . ';';
    $result_check_user = mysql_query($query_check_user) or die('Request down: ' . mysql_error());
    $checkUser = mysql_fetch_array($result_check_user);
    if ($checkUser['score'] < $score) {
        //inserting new scores
        $query_insert = 'INSERT INTO ' . $dbTable . '(name,score) VALUES (' . $name . ',' . $score . ') ON DUPLICATE KEY UPDATE score = VALUES(score);';
        $result = mysql_query($query_insert) or die('Request insert down: ' . mysql_error());
    }
    return $result;
    // clean
    if (isset($result)) {
        mysql_free_result($result);
    }
    // close
    mysql_close($link);
}
开发者ID:queridoamigo,项目名称:querido-amigo,代码行数:29,代码来源:functions.php

示例13: fromOpenID2CardID

function fromOpenID2CardID($openid)
{
    $mysql_host = SAE_MYSQL_HOST_M;
    $mysql_host_s = SAE_MYSQL_HOST_S;
    $mysql_port = SAE_MYSQL_PORT;
    $mysql_user = SAE_MYSQL_USER;
    $mysql_password = SAE_MYSQL_PASS;
    $mysql_database = SAE_MYSQL_DB;
    $mysql_table = "member";
    $mysql_state = "SELECT * FROM " . $mysql_table . " WHERE `openid` = '" . $openid . "'";
    $con = mysql_connect($mysql_host . ':' . $mysql_port, $mysql_user, $mysql_password, true);
    if (!$con) {
        die('Could not connect: ' . mysql_error());
    }
    mysql_query("SET NAMES 'UTF8'");
    mysql_select_db($mysql_database, $con);
    $result = mysql_query($mysql_state);
    $cardID = "";
    while ($row = mysql_fetch_array($result)) {
        $cardID = $row['cardid'];
        break;
    }
    mysql_close($con);
    return $cardID;
}
开发者ID:devsnippet,项目名称:WeChat-2,代码行数:25,代码来源:member.php

示例14: query

 function query($sql, $unbuffered = false)
 {
     if (defined('PUN_SHOW_QUERIES')) {
         $q_start = get_microtime();
     }
     if ($unbuffered) {
         $this->query_result = @mysql_unbuffered_query($sql, $this->link_id);
     } else {
         $this->query_result = @mysql_query($sql, $this->link_id);
     }
     if ($this->query_result) {
         if (defined('PUN_SHOW_QUERIES')) {
             $this->saved_queries[] = array($sql, sprintf('%.5f', get_microtime() - $q_start));
         }
         ++$this->num_queries;
         return $this->query_result;
     } else {
         if (defined('PUN_SHOW_QUERIES')) {
             $this->saved_queries[] = array($sql, 0);
         }
         $this->error_no = @mysql_errno($this->link_id);
         $this->error_msg = @mysql_error($this->link_id);
         return false;
     }
 }
开发者ID:highpictv,项目名称:forum,代码行数:25,代码来源:mysql.php

示例15: check_db

function check_db($dbhost, $dbuser, $dbpw, $dbname, $tablepre)
{
    if (!function_exists('mysql_connect')) {
        show_msg('undefine_func', 'mysql_connect', 0);
    }
    if (!@mysql_connect($dbhost, $dbuser, $dbpw)) {
        $errno = mysql_errno();
        $error = mysql_error();
        if ($errno == 1045) {
            show_msg('database_errno_1045', $error, 0);
        } elseif ($errno == 2003) {
            show_msg('database_errno_2003', $error, 0);
        } else {
            show_msg('database_connect_error', $error, 0);
        }
    } else {
        if ($query = @mysql_query("SHOW TABLES FROM {$dbname}")) {
            while ($row = mysql_fetch_row($query)) {
                if (preg_match("/^{$tablepre}/", $row[0])) {
                    return false;
                }
            }
        }
    }
    return true;
}
开发者ID:v998,项目名称:discuzx-en,代码行数:26,代码来源:install_function.php


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