本文整理汇总了PHP中mysql_query函数的典型用法代码示例。如果您正苦于以下问题:PHP mysql_query函数的具体用法?PHP mysql_query怎么用?PHP mysql_query使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mysql_query函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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++;
}
}
示例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
}
示例3: grabar_venta
public function grabar_venta($pedido, $cliente, $tipo_documento, $nro_documento, $serie_documento)
{
$query = "INSERT INTO ventas(ped_id,cli_id,ven_fecha,ven_estado,ven_nrodoc,tipc_id,ven_seriedoc) VALUES ('{$pedido}','{$cliente}','" . date('y-m-d') . "','0','{$nro_documento}','{$tipo_documento}','{$serie_documento}')";
$rs = mysql_query($query);
$_SESSION['venta_codigo'] = mysql_insert_id();
return $rs;
}
示例4: db
function db($dbhost, $dbuser, $dbpw, $dbname = '', $dbcharset = 'utf8', $pconnect = 0)
{
if ($pconnect) {
if (!($this->mlink = @mysql_pconnect($dbhost, $dbuser, $dbpw))) {
$this->halt('Can not connect to MySQL');
}
} else {
if (!($this->mlink = @mysql_connect($dbhost, $dbuser, $dbpw))) {
$this->halt('Can not connect to MySQL');
}
}
if ($this->version() > '4.1') {
if ('utf-8' == strtolower($dbcharset)) {
$dbcharset = 'utf8';
}
if ($dbcharset) {
mysql_query("SET character_set_connection={$dbcharset}, character_set_results={$dbcharset}, character_set_client=binary", $this->mlink);
}
if ($this->version() > '5.0.1') {
mysql_query("SET sql_mode=''", $this->mlink);
}
}
if ($dbname) {
mysql_select_db($dbname, $this->mlink);
}
}
示例5: getTangentText
function getTangentText($type, $keyword)
{
global $dbHost, $dbUser, $dbPassword, $dbName;
$link = @mysql_connect($dbHost, $dbUser, $dbPassword);
if (!$link) {
die("Cannot connect : " . mysql_error());
}
if (!@mysql_select_db($dbName, $link)) {
die("Cannot find database : " . mysql_error());
}
$result = mysql_query("SELECT sr_keywords, sr_text FROM soRandom WHERE sr_type = '" . $type . "' ORDER BY sr_ID ASC;", $link);
$tempCounter = 0;
while ($row = mysql_fetch_assoc($result)) {
$pKey = "/" . $keyword . "/";
$pos = preg_match($pKey, $row['sr_keywords']);
//echo $pos . " is pos<br>";
//echo $keyword;
//echo " is keyword and this is the search return: " . $row['keywords'];
if ($pos != 0) {
$text[$tempCounter] = stripslashes($row["sr_text"]);
$tempCounter++;
}
}
mysql_close($link);
//$text=htmlentities($text);
return $text;
}
示例6: Query
function Query($sqlString)
{
if (!($resourseId = @mysql_query($sqlString, $this->dbId))) {
die("<b>MySQL</b>: Unable to execute<br /><b>SQL</b>: " . $sqlString . "<br /><b>Error (" . mysql_errno() . ")</b>: " . @mysql_error());
}
return $resourseId;
}
示例7: executesql
function executesql($sql, $link)
{
if (!mysql_query($sql, $link)) {
die('Error: ' . mysql_error());
exit(0);
}
}
示例8: dataInsert
function dataInsert($table, $dataArray)
{
$fldArray = $dataArray;
$i = 0;
$j = 0;
$sql .= "insert into `" . $table . "` (";
while (list($key1, $value1) = each($fldArray)) {
$sql .= "`" . $key1 . "`";
$j++;
if ($j != count($fldArray)) {
$sql .= ",";
}
if ($j == count($fldArray)) {
$sql .= ") VALUES (";
}
}
while (list($key1, $value1) = each($dataArray)) {
$sql .= "'" . $value1 . "'";
$i++;
if ($i != count($dataArray)) {
$sql .= ",";
}
if ($i == count($dataArray)) {
$sql .= ")";
}
}
mysql_query($sql) or die(CHECK_QUERY . $sql);
$id = mysql_insert_id();
return $id;
}
示例9: checkIndividually
function checkIndividually()
{
#----------------------------------------------------------------------
global $competitionCondition, $chosenWhich;
echo "<hr /><p>Checking <b>" . $chosenWhich . " individual results</b>... (wait for the result message box at the end)</p>\n";
#--- Get all results (id, values, format, round).
$dbResult = mysql_query("\n SELECT\n result.id, formatId, roundId, personId, competitionId, eventId, result.countryId,\n value1, value2, value3, value4, value5, best, average\n FROM Results result, Competitions competition\n WHERE competition.id = competitionId\n {$competitionCondition}\n ORDER BY formatId, competitionId, eventId, roundId, result.id\n ") or die("<p>Unable to perform database query.<br/>\n(" . mysql_error() . ")</p>\n");
#--- Build id sets
$countryIdSet = array_flip(getAllIDs(dbQuery("SELECT id FROM Countries")));
$competitionIdSet = array_flip(getAllIDs(dbQuery("SELECT id FROM Competitions")));
$eventIdSet = array_flip(getAllIDs(dbQuery("SELECT id FROM Events")));
$formatIdSet = array_flip(getAllIDs(dbQuery("SELECT id FROM Formats")));
$roundIdSet = array_flip(getAllIDs(dbQuery("SELECT id FROM Rounds")));
#--- Process the results.
$badIds = array();
echo "<pre>\n";
while ($result = mysql_fetch_array($dbResult)) {
if ($error = checkResult($result, $countryIdSet, $competitionIdSet, $eventIdSet, $formatIdSet, $roundIdSet)) {
extract($result);
echo "Error: {$error}\nid:{$id} format:{$formatId} round:{$roundId}";
echo " ({$value1},{$value2},{$value3},{$value4},{$value5}) best+average({$best},{$average})\n";
echo "{$personId} {$countryId} {$competitionId} {$eventId}\n\n";
$badIds[] = $id;
}
}
echo "</pre>";
#--- Free the results.
mysql_free_result($dbResult);
#--- Tell the result.
noticeBox2(!count($badIds), "All checked results pass our checking procedure successfully.<br />" . wcaDate(), count($badIds) . " errors found. Get them with this:<br /><br />SELECT * FROM Results WHERE id in (" . implode(', ', $badIds) . ")");
}
示例10: consulta
function consulta($sql=""){
if($sql!="")
{
$this->consultaId=mysql_query($sql,$this->conexionId);
return $this->consultaId;
}
}
示例11: get_user_paid_expenses_test
function get_user_paid_expenses_test($userid_array)
{
if (is_array($userid_array)) {
$userids = implode(",", $userid_array);
} else {
$userids = $userid_array;
}
$sql = "SELECT user_id as userid, expense_id as exid, group_id, amount, UNIX_TIMESTAMP(expense_date) AS expensedate, \n description FROM expenses WHERE user_id in ({$userids})";
if (!($result = mysql_query($sql))) {
return false;
} else {
$total = 0;
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
$paid['users'][$row['userid']]['groups'][$row['group_id']][$row['exid']]['amount'] = $row['amount'];
$paid['users'][$row['userid']]['groups'][$row['group_id']][$row['exid']]['expense_date'] = date("j M Y", $row['expensedate']);
$paid['users'][$row['userid']]['groups'][$row['group_id']][$row['exid']]['description'] = $row['description'];
$paid['users'][$row['userid']]['groups'][$row['group_id']]['group_total'] += $row['amount'];
$paid['users'][$row['userid']]['user_total'] += $row['amount'];
$total += $row['amount'];
// format totals with two decimals
$paid['users'][$row['userid']]['groups'][$row['group_id']]['total'] = number_format($paid['users'][$row['userid']]['groups'][$row['group_id']]['total'], DECIMALS, DSEP, TSEP);
$paid['users'][$row['userid']]['total'] = number_format($paid['users'][$row['userid']]['total'], DECIMALS, DSEP, TSEP);
$paid['users'][$row['userid']]['groups'][$row['group_id']][$row['exid']]['running_total'] += $row['amount'] + $last_running[$row['userid']][$row['group_id']];
$last_running[$row['userid']][$row['group_id']] = $paid['users'][$row['userid']]['groups'][$row['group_id']][$row['exid']]['running_total'];
}
$paid['total'] = number_format($total, DECIMALS, DSEP, TSEP);
}
// array structure: ['users'][$userid]['groups'][$groupid][$expenseid]['amount|expense_date|description']
return $paid;
}
示例12: get_img_old
function get_img_old($id)
{
$query = mysql_query("select menu_img from menus \n\t\t\t\t\t\twhere menu_id = '" . $id . "'");
$result = mysql_fetch_array($query);
$row = $result['menu_img'];
return $row;
}
示例13: 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);
}
}
}
示例14: saveRatinglist
public function saveRatinglist()
{
foreach ($this->ratings as $player) {
//Controleren of speler al bestaat + ophalen id
$sql = "SELECT * FROM svn_leden WHERE knsb = " . $player["knsb"];
$query = mysql_query($sql);
if (mysql_num_rows($query) == 1) {
$data = mysql_fetch_assoc($query);
$player["id"] = $data["id"];
} elseif (mysql_num_rows($query) == 0) {
//Toevoegen van de speler
print_r($player);
}
//Controleren of de rating al bestaat
$sql = "SELECT * FROM svn_rating WHERE id = " . $player["id"] . " AND datum = '" . $this->ratingList . "'";
$query = mysql_query($sql);
if (mysql_num_rows($query) == 0) {
//Toevoegen rating
$sql = "INSERT INTO svn_rating VALUES ('',\"" . $this->ratingList . "\"," . $player["id"] . ",1," . $player["rating"] . ")";
mysql_query($sql);
}
}
$sql = "SELECT * FROM svn_leden WHERE knsb = " . $speler_geg["id"];
$result = mysql_query($sql);
$speler_dat = mysql_fetch_array($result);
if ($speler_geg["rating"] != "") {
$sql = "INSERT INTO svn_rating VALUES ('',\"" . $datum . "\"," . $speler_dat[0] . ",1," . $speler_geg["rating"] . ")";
//echo $sql;
mysql_query($sql);
}
}
示例15: insert_item
function insert_item()
{
// Connect to the 'test' database
// The parameters are defined in the teach_cn.inc file
// These are global constants
connect_and_select_db(DB_SERVER, DB_UN, DB_PWD, DB_NAME);
// Get the information entered into the webpage by the user
// These are available in the super global variable $_POST
// This is actually an associative array, indexed by a string
$itemNumber = mysql_real_escape_string($_POST['itemNumber']);
$itemDescription = mysql_real_escape_string($_POST['itemDescription']);
$category = mysql_real_escape_string($_POST['category']);
$departmentName = mysql_real_escape_string($_POST['departmentName']);
$purchaseCost = mysql_real_escape_string($_POST['purchaseCost']);
$retailPrice = mysql_real_escape_string($_POST['retailPrice']);
// Create a String consisting of the SQL command. Remember that
// . is the concatenation operator. $varname within double quotes
// will be evaluated by PHP
$insertStmt = "INSERT INTO Item (ItemNumber, ItemDescription, Category, DepartmentName,\n\t\t PurchaseCost, FullRetailPrice) values ( '{$itemNumber}','{$itemDescription}', '{$category}',\n '{$departmentName}', '{$purchaseCost}', '{$retailPrice}')";
//Execute the query. The result will just be true or false
$result = mysql_query($insertStmt);
$message = "";
if (!$result) {
$message = "Error in inserting Item. <br />Item Number: {$itemNumber}<br />Item Description:\n{$itemDescription} <br />Category:\n{$category}\n<br />Department\n Name: {$departmentName} <br />" . mysql_error();
} else {
$message = "Data for Item inserted successfully. <br />Item Number: {$itemNumber}<br />Item Description: {$itemDescription} <br />Category: {$category} <br />Department Name: {$departmentName}";
}
ui_show_item_insert_result($message, $itemNumber, $itemDescription, $category, $departmentName, $purchaseCost, $retailPrice);
}