本文整理汇总了PHP中mysqlConnection函数的典型用法代码示例。如果您正苦于以下问题:PHP mysqlConnection函数的具体用法?PHP mysqlConnection怎么用?PHP mysqlConnection使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mysqlConnection函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: acessaBD
function acessaBD($comando, $tabela, $campos = '', $criterios = '')
{
//, $mysql_host, $mysql_user_name, $mysql_password, $mysql_db_name) {
mysqlConnection();
//$mysql_host,$mysql_user_name,$mysql_password,$mysql_db_name);
//Acessa BD
//Configura query para UTF-8
mysql_query("SET NAMES 'utf8'");
mysql_query('SET character_set_connection=utf8');
mysql_query('SET character_set_client=utf8');
mysql_query('SET character_set_results=utf8');
switch ($comando) {
case 'SELECT':
//Retorna o array com o recordset da query
$query = $comando . ' ' . $campos . ' FROM ' . $tabela . ' WHERE ' . $criterios;
$rs = mysql_query($query) or die(mysql_error());
if (mysql_num_rows($rs) < 1) {
return 0;
} else {
$row = mysql_fetch_array($rs) or die(mysql_error());
}
return $row;
break;
case 'UPDATE':
//Retorna 1 ou 2
$query = $comando . ' ' . $tabela . ' SET ' . $campos . ' WHERE ' . $criterios;
if (mysql_query($query) or die(mysql_error())) {
return 1;
} else {
return 2;
}
//Erro no UPDATE
break;
case 'INSERT':
$query = $comando . ' INTO ' . $tabela . ' VALUES ' . $campos;
if (mysql_query($query) or die(mysql_error())) {
return 1;
} else {
return 0;
}
break;
case 'DELETE':
$numero = array();
$query = $comando . ' FROM ' . $tabela . ' WHERE ' . $criterios;
mysql_query($query);
if (!mysql_affected_rows()) {
return 0;
} else {
return $numero[mysql_affected_rows()];
}
break;
}
}
示例2: session_start
<?php
session_start();
if (!$_SESSION['login']) {
header('Location: ../km/default.asp');
}
header('Content-Type: text/html; charset=utf-8');
require_once '../modulos/dao.php';
require_once '../modulos/envia_email.php';
mysqlConnection();
mysql_query("SET NAMES 'utf8'");
mysql_query('SET character_set_connection=utf8');
mysql_query('SET character_set_client=utf8');
mysql_query('SET character_set_results=utf8');
// get the q parameter from URL
$nome = $_GET['nome'];
$pdv_empresa = $_GET['pdv_empresa'];
$desc_empresa = $_GET['desc_empresa'];
$desc_regional = $_GET['desc_regional'];
$periodicidade = $_GET['periodicidade'];
$tipo_empresa = $_REQUEST['cod_tipo_empresa'];
$nvl = $_SESSION['nivel_acesso'];
/*
$campos = "cred.*";
$tabela = "credenciados cred INNER JOIN consultor c ON (c.cod_consultor = cred.cod_consultor)";
$criterios = "cred.pdv = " . $_GET["pdv"];
$row = mysql_fetch_array($consulta_especialista);
*/
//Lista Consultores
$campos = "cod_consultor, nome";
示例3: xml_response
*/
xml_response('true', 'true', 'Success', 'Your form was successfully posted. Thank you.', 'OK');
} else {
$login_success = false;
if (isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) {
if ($user_name == $_SERVER['PHP_AUTH_USER'] && $password == $_SERVER['PHP_AUTH_PW']) {
$login_success = true;
}
}
if ($login_success) {
echo '<html>';
echo '<body style="padding:20px;">';
echo '<a href="index.php"><img src="logo.png" alt="FormEntry Logo" width="100" height="100" border="0" /></a>';
if (isset($_GET['db']) && $_GET['db'] == 'mysql') {
echo '<h1>FormEntry MySQL</h1>';
mysqlConnection($mysql_host, $mysql_user_name, $mysql_password, $mysql_db_name);
$mysql_result_id = mysql_query("SELECT * FROM index");
$mysql_result = array();
while ($row = mysql_fetch_array($mysql_result_id)) {
array_push($mysql_result, $row);
}
if (count($mysql_result) > 0) {
echo '<table style="border:1px solid #ccc"><thead style="background:#444;color:#fff;"><tr>';
$i = 0;
foreach ($mysql_result as $mysql_head_row) {
if ($i < 1) {
$j = 0;
foreach ($mysql_head_row as $mysql_head_key => $mysql_head_val) {
echo $j % 2 ? '<th>' . strtoupper(str_replace("_", " ", $mysql_head_key)) . '</th>' : '';
$j++;
}