本文整理汇总了PHP中msql_error函数的典型用法代码示例。如果您正苦于以下问题:PHP msql_error函数的具体用法?PHP msql_error怎么用?PHP msql_error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了msql_error函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: DropDatabase
function DropDatabase(&$db, $name)
{
if (!$db->Connect()) {
return 0;
}
if (!msql_drop_db($name, $db->connection)) {
return $db->SetError("Drop database", msql_error());
}
return 1;
}
示例2: define
//name of database user
define('DB_PW', 'W3arethebest');
//password
define('DB_HOST', 'localhost');
//where the database is running
//a variable created based on the connection to the sql database
$dbLink = mysql_connect(DB_HOST, DB_USER, DB_PW);
if (!$dbLink) {
//checks if there is a valid db connection; if not, execute statement
die('Connection failed: ' . msql_error());
}
//selects the mysql database based on the link and stores it in a variable
$selectedDB = mysql_select_db(DB_NAME, $dbLink);
if (!$selectedDB) {
//checks if there is a valid db selected; if not, execute statement
die('Error: ' . DB_NAME . ': ' . msql_error());
}
//Collect these values from the form and store them into a variable
$eID = $_GET['e_ID'];
$eSDate = $_POST['Start_Date'];
$eSDate = date("Y-m-d", strtotime($eSDate));
$eSDate = mysql_real_escape_string($eSDate);
$eEDate = $_POST['End_Date'];
$eEDate = date("Y-m-d", strtotime($eEDate));
$eEDate = mysql_real_escape_string($eEDate);
$eSTime = $_POST['timeH'] . ":" . $_POST['timeM'] . ":00";
$eLocation = $_POST['Location'];
$eLocation = mysql_real_escape_string($eLocation);
$ePUA = $_POST['PUA'];
$ePUA = mysql_real_escape_string($ePUA);
$eName = $_POST['Name'];
示例3: errorNative
/**
* Gets the DBMS' native error message produced by the last query
*
* @return string the DBMS' error message
*/
function errorNative()
{
return @msql_error();
}
示例4: msql_error
<?php
require_once "mysql.php";
echo msql_error();
function carddata($echo = false)
{
$result = mysql_query("SELECT * FROM card");
$cards = "";
$data = "{";
while ($line = mysql_fetch_array($result)) {
if (strlen($cards) > 0) {
$cards .= ",";
}
$id = $line['ID'];
while (strlen($id) < 4) {
$id = "0" . $id;
}
$cards .= "\"" . $id . "\"";
if (strlen($data) > 1) {
$data .= ',';
}
$data .= '"' . $id . '":{"name":"' . $line['name'] . '","mana":' . $line['mana'] . ',"range":' . $line['range'];
if ($line['direction']) {
$data .= ',"direction":"' . $line['direction'] . '"';
}
$effects = mysql_query("SELECT * FROM card INNER JOIN cardeffect ON card.ID = cardID INNER JOIN effect ON effect.ID = effectID WHERE card.ID = " . $line['ID']);
/*
* === Feedback Alpers, Jan. 5 ===
*
* Schön effizienter Code fürs Einlesen der Datensätze.
*/
示例5: die
<?php
#if(!mysql_connect("mysql2.gear.host","safetaxi","Safetaxi1!"))
if (!mysql_connect("localhost", "root", "pass")) {
die('oops connection problem ! --> ' . mysql_error());
}
if (!mysql_select_db("dbtest")) {
die('oops database selection problem ! --> ' . mysql_error());
}
//selecting which database to use here
mysql_select_db("dbtest") or die("no database by that name" . msql_error());
//now here change the name of the table you are selecting information from. But copy and past this and create another php file if your are going to use another table.
$result = mysql_query("SELECT * FROM taxi_drivers ") or die('Errant query:');
$rows = mysql_num_rows($result);
$return_arr = array();
while ($row2 = mysql_fetch_assoc($result)) {
$return_arr[] = $row2;
}
echo json_encode($return_arr);
示例6: fetchInto
/**
* Fetch a row and insert the data into an existing array.
*
* Formating of the array and the data therein are configurable.
* See DB_result::fetchInto() for more information.
*
* @param resource $result query result identifier
* @param array $arr (reference) array where data from the row
* should be placed
* @param int $fetchmode how the resulting array should be indexed
* @param int $rownum the row number to fetch
*
* @return mixed DB_OK on success, null when end of result set is
* reached or on failure
*
* @see DB_result::fetchInto()
* @access private
*/
function fetchInto($result, &$arr, $fetchmode, $rownum = null)
{
if ($rownum !== null) {
if (!@msql_data_seek($result, $rownum)) {
return null;
}
}
if ($fetchmode & DB_FETCHMODE_ASSOC) {
$arr = @msql_fetch_array($result, MSQL_ASSOC);
if ($this->options['portability'] & DB_PORTABILITY_LOWERCASE && $arr) {
$arr = array_change_key_case($arr, CASE_LOWER);
}
} else {
$arr = @msql_fetch_row($result);
}
if (!$arr) {
if ($error = @msql_error()) {
return $this->raiseError($error);
} else {
return null;
}
}
if ($this->options['portability'] & DB_PORTABILITY_RTRIM) {
$this->_rtrimArrayValues($arr);
}
if ($this->options['portability'] & DB_PORTABILITY_NULL_TO_EMPTY) {
$this->_convertNullArrayValuesToEmpty($arr);
}
return DB_OK;
}
示例7: die
<?php
#if(!mysql_connect("mysql2.gear.host","safetaxi","Safetaxi1!"))
if (!mysql_connect("mysql2.gear.host", "bobosampledb", "safetaxi!")) {
die('oops connection problem ! --> ' . mysql_error());
}
if (!mysql_select_db("bobosampledb")) {
die('oops database selection problem ! --> ' . mysql_error());
}
//selecting which database to use here
mysql_select_db("bobosampledb") or die("no database by that name" . msql_error());
//now here change the name of the table you are selecting information from. But copy and past this and create another php file if your are going to use another table.
$result = mysql_query("SELECT * FROM taxi_drivers ") or die('Errant query:');
$rows = mysql_num_rows($result);
$return_arr = array();
while ($row2 = mysql_fetch_assoc($result)) {
$return_arr[] = $row2;
}
echo json_encode($return_arr);
示例8: fetchInto
function fetchInto($result, &$ar, $fetchmode, $rownum = null)
{
if ($rownum !== null) {
if (!@msql_data_seek($result, $rownum)) {
return null;
}
}
if ($fetchmode & DB_FETCHMODE_ASSOC) {
$ar = @msql_fetch_array($result, MSQL_ASSOC);
} else {
$ar = @msql_fetch_row($result);
}
if (!$ar) {
if ($error = msql_error()) {
return $this->raiseError($error);
} else {
return null;
}
}
return DB_OK;
}
示例9: while
echo "<ul class='top-list' style='display: inline-block;'><li class='loc'>Bangalore(West)</li>";
$i = 0;
while ($i < 10) {
echo "<li>" . $top_list[$i]['medName'] . "</li>";
$i++;
}
echo "</ul></center>";
unset($top_list);
?>
</div>
</div>
<!-- <div class="graphs"></div> -->
<?php
if (isset($_GET['med'])) {
$name = $_GET['med'];
$conn = mysql_connect(DB_HOST, DB_USER) or die(msql_error());
mysql_select_db("Codesteins") or die(mysql_error());
$query = "SELECT sno,medName FROM allmeds WHERE medName LIKE '%" . $name . "'";
// echo $query;
$result = mysql_query($query) or die(mysql_error());
$arr = mysql_fetch_array($result) or die(mysql_error());
// echo $arr[0];
// echo type($arr);
// print_r($arr);
echo "<div style='text-align: center;'><h1>The graph below shows the sales of " . strtoupper($arr[1]) . "</h1></div>";
// echo $arr['sno'];
if (empty($arr)) {
# code...
echo "<span class='empty-error'>No matches found. Please check the name you've entered.</span>";
}
if (isset($arr['sno'])) {
示例10: FetchResultArray
function FetchResultArray($result, &$array, $row)
{
if (isset($this->limits[$result])) {
if ($row > $this->limits[$result][1]) {
return $this->SetError("Fetch result array", "attempted to retrieve a row beyhond the result limit");
}
$actual_row = $row + $this->limits[$result][0];
} else {
$actual_row = $row;
}
if (!msql_data_seek($result, $row) || !($array = msql_fetch_row($result))) {
return $this->SetError("Fetch result array", msql_error());
}
$this->highest_fetched_row[$result] = max($this->highest_fetched_row[$result], $row);
return $this->ConvertResultRow($result, $array);
}
示例11: connect_fbql
function connect_fbql($host, $user, $pass, $db)
{
$this->fbsql_link = fbsql_pconnect($host, $user, $pass);
if ($this->fbsql_link == 0) {
return false;
}
if (!fbsql_select_db($db, $this->fbsql_link)) {
print "Database Error " . msql_error() . "\n";
return false;
}
return $this->fbsql_link;
}
示例12: delete_user_core
//.........这里部分代码省略.........
//
// Eleventh sql query deletes the user from the banlist table
//
// ***************************************************************************
$sql = "DELETE FROM `{$phpbb_banlist}` WHERE `ban_userid`={$user_id}";
if (!($result = mysql_query($sql))) {
die('<font size="4"><b>Error deleting user from the banlist table:</b></font><br /><b>Line:</b> ' . __LINE__ . '<br /><b>File:</b> ' . $_SERVER['PHP_SELF'] . "<br /><b>Query:</b> {$sql}<br /><b>MySQL Error:</b> " . mysql_error());
}
// ***************************************************************************
//
// Twelfth sql query deletes the user from the sessions table
//
// ***************************************************************************
// This delete section was added in .19, so a check is done before using it incase
// the admin is running an older version of phpbb
if ($phpbb_version >= 0.19) {
$sql = "DELETE FROM `{$phpbb_sessions}` WHERE `session_user_id`={$user_id}";
if (!($result = mysql_query($sql))) {
die('<font size="4"><b>Error deleting user from the sessions table:</b></font><br /><b>Line:</b> ' . __LINE__ . '<br /><b>File:</b> ' . $_SERVER['PHP_SELF'] . "<br /><b>Query:</b> {$sql}<br /><b>MySQL Error:</b> " . mysql_error());
}
}
// ***************************************************************************
//
// Twelfth sql query deletes the user from the sessions_keys table
//
// ***************************************************************************
// This delete section was added in .19, so a check is done before using it incase
// the admin is running an older version of phpbb
if ($phpbb_version >= '.0.19') {
// First check if the sesssions keys table exists
// (Since alot of .19 boards dont have it due to incomplete updates
$sql_key_check = "SHOW TABLES LIKE '{$phpbb_sessions_keys}'";
if (!($result_key_check = mysql_query($sql_key_check))) {
die('<font size="4"><b>Error selecting session keys table:</b></font><br /><b>Line:</b> ' . __LINE__ . '<br /><b>File:</b> ' . $_SERVER['PHP_SELF'] . "<br /><b>Query:</b> {$sql}<br /><b>MySQL Error:</b> " . mysql_error());
}
// This section actually checks if the table exists, if not it skips
// deleting the user from this table
if (mysql_fetch_array($result_key_check)) {
$sql = "DELETE FROM `{$phpbb_sessions_keys}` WHERE `user_id`={$user_id}";
if (!($result = mysql_query($sql))) {
die('<font size="4"><b>Error deleting user from the sessions_keys table:</b></font><br /><b>Line:</b> ' . __LINE__ . '<br /><b>File:</b> ' . $_SERVER['PHP_SELF'] . "<br /><b>Query:</b> {$sql}<br /><b>MySQL Error:</b> " . mysql_error());
}
}
}
// ***************************************************************************
//
// The final sql query collets the to/from PMs with the user's id & deletes them
//
// ***************************************************************************
// If retain_pms is set to true, change PM author to anonymous instead of deleting them
if ($retain_pms == true) {
// This query sets the from_user_id to the anonymous account so the PMs dont have to be deleted
$sql = "UPDATE `{$phpbb_privmsgs}` SET `privmsgs_from_userid`=-1 WHERE `privmsgs_from_userid`={$user_id}";
if (!($result = mysql_query($sql))) {
die('<font size="4"><b>Error setting from PM from_user_id to anonymous:</b></font><br /><b>Line:</b> ' . __LINE__ . '<br /><b>File:</b> ' . $_SERVER['PHP_SELF'] . "<br /><b>Query:</b> {$sql}<br /><b>MySQL Error:</b> " . mysql_error());
}
// This query sets the to_user_id to the anonymous account so the PMs dont have to be deleted
$sql = "UPDATE `{$phpbb_privmsgs}` SET `privmsgs_to_userid`=-1 WHERE `privmsgs_to_userid`={$user_id}";
if (!($result = mysql_query($sql))) {
die('<font size="4"><b>Error setting from PM to_user_id to anonymous:</b></font><br /><b>Line:</b> ' . __LINE__ . '<br /><b>File:</b> ' . $_SERVER['PHP_SELF'] . "<br /><b>Query:</b> {$sql}<br /><b>MySQL Error:</b> " . mysql_error());
}
} else {
$sql = "SELECT `privmsgs_id` FROM `{$phpbb_privmsgs}` WHERE `privmsgs_from_userid`={$user_id} OR `privmsgs_to_userid`={$user_id}";
if (!($result = mysql_query($sql))) {
die('<font size="4"><b>Error selecting PMs for the user:</b></font><br /><b>Line:</b> ' . __LINE__ . '<br /><b>File:</b> ' . $_SERVER['PHP_SELF'] . "<br /><b>Query:</b> {$sql}<br /><b>MySQL Error:</b> " . mysql_error());
}
// Debugging info:
// echo "<br />$sql<br />";
// This section marks and assigns the resulting PMs into the $marked array
while ($myrow = mysql_fetch_array($result)) {
$marked[] = $myrow['privmsgs_id'];
}
// Makes mark an empty array if the user has no PMs
if (!isset($marked)) {
$marked = array();
}
// This section actually goes through the list and deletes the PMs
// Debugging info:
// echo '<pre>';
// print_r( $marked );
if (count($marked)) {
$delete_id = implode(',', $marked);
// Debugging info:
// echo "<br />$delete_id";
$sql = "DELETE FROM `{$phpbb_privmsgs_text}` WHERE `privmsgs_text_id` IN ( {$delete_id} )";
// Debugging info:
// echo "<br />$sql";
if (!($result = mysql_query($sql))) {
die('Error deleting user PMs:<br />Line: ' . __LINE__ . '<br />File: ' . $_SERVER['PHP_SELF'] . "<br />Query: {$sql}<br />MySQL Error: " . msql_error());
}
$sql = "DELETE FROM `{$phpbb_privmsgs}` WHERE `privmsgs_id` IN ( {$delete_id} )";
// Debugging info:
// echo "<br />$sql";
if (!($result = mysql_query($sql))) {
die('Error deleting user Pms:<br />Line: ' . __LINE__ . '<br />File: ' . $_SERVER['PHP_SELF'] . "<br />Query: {$sql}");
}
}
}
// And thats it! The user should now be fully and properly deleted!
}
示例13: SaveCopyToArchive
function SaveCopyToArchive($dbi, $pagename, $pagehash)
{
global $ArchivePageStore;
$pagehash = MakeDBHash($pagename, $pagehash);
// $pagehash["content"] is now an array of strings
// of MSQL_MAX_LINE_LENGTH
if (IsInArchive($dbi, $pagename)) {
$PAIRS = "author='{$pagehash['author']}'," . "created={$pagehash['created']}," . "flags={$pagehash['flags']}," . "lastmodified={$pagehash['lastmodified']}," . "pagename='{$pagehash['pagename']}'," . "refs='{$pagehash['refs']}'," . "version={$pagehash['version']}";
$query = "UPDATE {$ArchivePageStore['table']} SET {$PAIRS} WHERE pagename='{$pagename}'";
} else {
// do an insert
// build up the column names and values for the query
$COLUMNS = "author, created, flags, lastmodified, " . "pagename, refs, version";
$VALUES = "'{$pagehash['author']}', " . "{$pagehash['created']}, {$pagehash['flags']}, " . "{$pagehash['lastmodified']}, '{$pagehash['pagename']}', " . "'{$pagehash['refs']}', {$pagehash['version']}";
$query = "INSERT INTO archive ({$COLUMNS}) VALUES({$VALUES})";
}
// echo "<p>Query: $query<p>\n";
// first, insert the metadata
$retval = msql_query($query, $dbi['dbc']);
if ($retval == false) {
printf(gettext("Insert/update into table 'archive' failed: %s"), msql_error());
print "<br>\n";
}
// second, insert the page data
// remove old data from page_table
$query = "delete from {$ArchivePageStore['page_table']} where pagename='{$pagename}'";
// echo "Delete query: $query<br>\n";
$retval = msql_query($query, $dbi['dbc']);
if ($retval == false) {
printf(gettext("Delete on %s failed: %s"), $ArchivePageStore[page_table], msql_error());
print "<br>\n";
}
// insert the new lines
reset($pagehash["content"]);
for ($x = 0; $x < count($pagehash["content"]); $x++) {
$line = addslashes($pagehash["content"][$x]);
$query = "INSERT INTO {$ArchivePageStore['page_table']} " . "(pagename, lineno, line) " . "VALUES('{$pagename}', {$x}, '{$line}')";
// echo "Page line insert query: $query<br>\n";
$retval = msql_query($query, $dbi['dbc']);
if ($retval == false) {
printf(gettext("Insert into %s failed: %s"), $ArchivePageStore[page_table], msql_error());
print "<br>\n";
}
}
}
示例14: define
<?php
include "main_function.php";
define('NUMBER_OF_TIPS', 3);
define('NUMBER_OF_NEIGHBOUR_FOR_TOTEM', 6);
DEFINE('NUMBER_OF_NEIGHBOUR', 3);
$db_host = "localhost";
$db_username = "root";
$db_pass = "123";
$db_name = "rted";
$dbhandle = mysql_connect($db_host, $db_username, $db_pass) or die("Unable to connect to MySQL: " . msql_error());
$mysql_rted = mysql_select_db($db_name, $dbhandle) or die("Could not select tips");
//There are 5 tables in the database: building, building_neighbour, building_tips, energy_consumption, tips;
date_default_timezone_set('America/Vancouver');
//sample URL = http://localhost:9999/index.php?building_name=Dene, replace 'Dene' if you want to check other buildings
if (empty($_GET["building_name"])) {
echo "Please give a building name<br>";
exit;
}
//1.Get the url and building_name
$building_name = $_GET["building_name"];
//OUTPUT VALUE!!!
$building_id = buildingID($building_name);
$clock = date('H:i A');
//OUTPUT VALUE!!!
$today = get_today_lastweek()[0];
//$lastweek = get_today_lastweek()[1];
$lastweek = date('m/d/Y H:i:s', mktime(16, 45, 0, 1, 4, 2016));
$number_tips = constant('NUMBER_OF_TIPS');
if ($building_name == 'Totem') {
$number_neighboor = constant('NUMBER_OF_NEIGHBOUR_FOR_TOTEM');