** description : execute la requete et gere les cas d'erreur */ function dbQuery($requete) { global $db; $res = mysql_db_query($db['name'], $requete); if (!$res) { print $requete; die("problème d'acces à la base de données dbQuery " . $requete . " \n" . mysql_error()); }
function getSolution($pid) { $ret = ""; require "../include/const.inc.php"; require "../include/db_info.inc.php"; $con = mysql_connect($DB_HOST, $DB_USER, $DB_PASS); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_db_query($DB_NAME, "set names utf8", $con); mysql_set_charset("utf8", $con); mysql_select_db($DB_NAME, $con); $sql = "select `solution_id`,`language` from solution where problem_id={$pid} and result=4 order by language"; // echo $sql; $result = mysql_db_query($DB_NAME, $sql, $con); if ($result && ($row = mysql_fetch_row($result))) { $solution_id = $row[0]; $language = $language_name[$row[1]]; echo $language; mysql_free_result($result); $sql = "select source from source_code where solution_id={$solution_id}"; $result = mysql_query($sql) or die(mysql_error()); if ($row = mysql_fetch_object($result)) { $ret = $row->source; } mysql_free_result($result); } mysql_close($con); return $ret; }
public function __construct($dbname) { $this->mysqli = new mysqli($this->dblocation, 'root', '', $dbname); if (!$this->mysqli) { die('Error connection: ' . mysql_error()); } else { //echo 'Suecces conection'; } if (!mysqli_select_db($this->mysqli, $dbname)) { if (mysql_query("CREATE DATABASE " . $dbname)) { echo '<br> BD ' . $dbname . ' create success'; } $sql = "CREATE TABLE MyGuests (\r\n id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,\r\n title VARCHAR(100) NOT NULL,\r\n category INT(100),\r\n description VARCHAR(150),\r\n source VARCHAR(50),\r\n datetime TIMESTAMP\r\n )"; if (mysql_db_query($dbname, $sql)) { echo '<br> BD MyGuests success create'; } $sql = "CREATE TABLE category (\r\n id INT(6),\r\n name VARCHAR(100)\r\n )"; if (mysql_db_query($dbname, $sql)) { echo '<br> BD category success create'; } $sql = "INSERT INTO category(id, name)\r\n VALUES\r\n (1, 'Politics'),\r\n (2, 'Culture'),\r\n (3, 'Sport')"; if (mysql_db_query($dbname, $sql)) { echo '<br> BD category insert success'; } } else { //echo '<br> БД существует'; } }
function get_content($database, $table, $fp) { // get content of data global $delimiter; $result = mysql_db_query($database, "SELECT * FROM {$table}") or die("Cannot get content of table"); while ($row = mysql_fetch_row($result)) { $insert = "INSERT INTO {$table} VALUES ("; // command for later SQL-restore for ($j = 0; $j < mysql_num_fields($result); $j++) { // content for later SQL-restore if (!isset($row[$j])) { $insert .= "NULL,"; } elseif (isset($row[$j])) { $insert .= "'" . addslashes($row[$j]) . "',"; } else { $insert .= "'',"; } } $insert = ereg_replace(",\$", "", $insert); $insert .= "){$delimiter}\n"; // create row delimiter gzwrite($fp, $insert); // now write the complete content into backup file } gzwrite($fp, "\n\n"); mysql_free_result($result); }
function da_sql_query($link, $config, $query) { if ($config[sql_debug] == 'true') { print "<b>DEBUG(SQL,MYSQL DRIVER): Query: <i>{$query}</i></b><br>\n"; } return @mysql_db_query($config[sql_database], $query, $link); }
public function dbQuery($sql) { //test sql $this->sql = $sql; $this->queryResult = mysql_db_query($this->db, $this->sql, $this->connection); return $queryResult; }
function do_xml() { $_str = $_str_temp = ''; // коннектимся f_mysql_connect(); // выбираем $result = mysql_db_query($GLOBALS["dbname"], "SELECT * FROM news where status=1 order by id desc limit " . ___findpole("select zna from config where id=9", 'zna')); // формируем все новости $name_file = '/rss/all.xml'; for ($i = 0; $i < mysql_numrows($result); $i++) { $find = mysql_fetch_array($result); // елементы для замены $mass_element_for_parsing = array("%zag%", "%link%", "%text%", "%date%"); // заменяеміе значения $mass_result_for_parsing = array($find['zag'], MAIN_PATH . "/news/idnews/" . $find['id'] . '/type/' . $find['type'], strip_tags(htmlspecialchars(substr($find['text'], 0, 150))), $find['date']); // парсим данные $_str_temp = parsing_tpl($name_file, $mass_element_for_parsing, $mass_result_for_parsing, $_str_temp); } // основной шаблон $name_file = '/rss/template.xml'; // елементы для замены $mass_element_for_parsing = array("%zag%", "%www%", "%tegs%"); // заменяеміе значения $mass_result_for_parsing = array(iconv('CP1251', 'UTF-8', 'Новости'), iconv('CP1251', 'UTF-8', ADRESS_SITE), iconv('CP1251', 'UTF-8', $_str_temp)); // парсим данные $_str = parsing_tpl($name_file, $mass_element_for_parsing, $mass_result_for_parsing, $_str); write_keh(HOST . '/rss/ru.xml', $_str); }
function send_sql($db, $sql) { if (! $res=mysql_db_query($db, $sql)) { echo mysql_error(); exit; } return $res; }
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; }
function BigIDtoBig($BigID, $table) { $sql = "select * from " . $table . " where id=" . $BigID . ""; global $dbname; $result = mysql_db_query($dbname, $sql); $rs = mysql_fetch_array($result); return $rs["BigClass"]; }
function DB_QUERY($SQL) { #echo $SQL. "<BR>"; mysql_connect($GLOBALS["SQL_HOST"], $GLOBALS["SQL_USER"], $GLOBALS["SQL_PASS"]) or die("<meta http-equiv='Content-Type' content='text/html; charset=utf-8' /><div align=center><h2>Server 忙錄中,請稍後再試;或請連絡管理人員</h2></div>"); mysql_query("SET NAMES UTF8"); $RES = mysql_db_query($GLOBALS["SQL_NAME"], $SQL) or die("<meta http-equiv='Content-Type' content='text/html; charset=utf-8' /><div align=center><h2>資料表錯誤,請連絡管理人員</h2></div>" . mysql_error()); return $RES; }
function getAllChild($MemberID) { include "includes/config.php"; $sql = "SELECT COUNT(MemberID) as num FROM {$TMember} WHERE ParentID ='{$MemberID}' AND Status ='A' AND MemberType='S'"; $q = mysql_db_query($dbname, $sql) or die($sql); $result = mysql_fetch_array($q); return $result["num"]; }
function getProvince($pid) { include "includes/config.php"; $sql = "SELECT PROVINCE_NAME FROM {$TProvince} WHERE PROVINCE_ID = '{$pid}'"; $q = mysql_db_query($dbname, $sql) or die($sql); $result = mysql_fetch_array($q); return $result["PROVINCE_NAME"]; }
function DbSelectQuery($sql, $db_database, $conn) { if (@($result = mysql_db_query($db_database, $sql, $conn))) { return $result; } else { $this->ErrorMsg(mysql_error()); exit; } }
public function unblock($fecha1, $hora1, $usuario, $basedatos) { $q = "UPDATE usuarios set\r\nfechaIngreso='" . $fecha1 . "',\r\nhoraIngreso='" . $hora1 . "',\r\nllave='',\r\nstatus='inactivo'\r\nWHERE\r\n\r\nusuario='" . $usuario . "' \r\n"; mysql_db_query($basedatos, $q); echo mysql_error(); ?> <?php }
public function validaSubModulo($campo, $codModulo, $codSM, $usuario, $basedatos) { $checaModuloScript = "Select * From usuariosSubmodulos WHERE codModulo='" . $codModulo . "' \r\nand codSM = '" . $codSM . "' and \r\nusuario1 = '" . $usuario . "'"; $resScript = mysql_db_query($basedatos, $checaModuloScript); $resulScripModulo = mysql_fetch_array($resScript); echo mysql_error(); //return $resulScripModulo['usuario']; return $campo = $resulScripModulo['usuario']; }
function generateTable($strsql) { $mysql_server_name = SERVER_NAME; // mysql server name $mysql_username = USER_NAME; // mysql user name $mysql_password = USER_PASSWORD; // mysql user password $mysql_database = DB_NAME; // mysql database name // connect to server $conn = mysql_connect($mysql_server_name, $mysql_username, $mysql_password); if (!$conn) { die('Could not connect: ' . mysql_error()); } // run sql command $result = mysql_db_query($mysql_database, $strsql, $conn); // fetch sql result $row = mysql_fetch_row($result); /* to print out the field name from sql result echo "</b><tr></b>"; for ($i=0; $i<mysql_num_fields($result); $i++) { echo '<td><b>'. mysql_field_name($result, $i); echo "</b></td></b>"; } echo "</tr></b>"; */ mysql_data_seek($result, 0); // $tmp = 'tmp'; while ($row = mysql_fetch_row($result)) { echo "<tr><b>"; for ($i = 0; $i < mysql_num_fields($result); $i++) { echo '<td>'; if ($i == 0) { if ($tmp == $row[$i]) { echo ''; } else { echo $row[$i]; $tmp = $row[$i]; } } else { echo $row[$i]; } echo '</td>'; } echo "</tr></b>"; } echo "</table></b>"; // release mysql_free_result($result); // disconnection mysql_close($conn); }
function Login() { $username = $_POST['username']; $password = $_POST['password']; if ($username && $password) { $conn = mysql_connect(HOST, USER, PASS) or die("Whoops"); // Connect to the database, or if connection fails print error message. $password = md5($password); // encode submited password with MD5 encryption and store it back in the same variable. If not on a windows box, I suggest you use crypt() $sql = "select * from users where loginname='{$username}'"; // query statment that gets the username/password from 'login' where the username is the same as the one you submited $r = mysql_db_query(DB, $sql); // Execute Query // if no rows for that database come up, redirect. if (!mysql_num_rows($r)) { mysql_close($conn); header("Location: index.php"); // This is the redirection, notice it uses $SCRIPT_NAME which is a predefined variable with the name of the script in it. } else { $passed = @mysql_connect(HOST, USER, PASS); } mysql_select_db(DB); if (!$passed) { //echo 'Could not connect: ' . mysql_error(); echo "<center><font color=\"#FF0000\"><b>Invalid User Name or Password</b></font></center>"; $_SESSION["logged"] = 0; $_SESSION["userid"] = ""; } else { //$sql="select pass('$password') as pass, fname, sname from users"; $sql = "select pass, fname, sname, loginname, userid from users where loginname='{$username}'"; $password = mkr_query($sql, $passed); $password = mysql_fetch_array($password); $_SESSION["employee"] = $password['fname'] . " " . $password['sname']; $_SESSION["loginname"] = $password['loginname']; $_SESSION["userid"] = $password['userid']; $password = $password['pass']; //****************************************************************** //*Not the best option but produce the required results - unencrypted password saved to a cookie //****************************************************************** setcookie("data_login", "{$username} {$password}", time() + 60 * 30); // Set the cookie named 'candle_login' with the value of the username (in plain text) and the password (which has been encrypted and serialized.) $_SESSION["logged"] = 1; // set variable $msg with an HTML statement that basically says redirect to the next page. The reason we didn't use header() is that using setcookie() and header() at the sametime isn't 100% compatible with all browsers, this is more compatible. $msg = "<meta http-equiv=\"Refresh\" content=\"0;url=./index.php\">"; //put index.php } } else { echo "<center><font color=\"#FF0000\"><b>Enter your UserName and Password to login on to the system</b></font></center>"; $_SESSION["logged"] = 0; } if ($msg) { echo $msg; } //if $msg is set echo it, resulting in a redirect to the next page. //} }
public function statusEstudio($numeroE, $nCuenta, $keyCAP, $basedatos) { $sql = "select statusEstudio \r\nFROM \r\ncargosCuentaPaciente \r\nWHERE numeroE = '" . $numeroE . "' AND nCuenta='" . $nCuenta . "' AND keyCAP='" . $keyCAP . "'"; $r = mysql_db_query($basedatos, $sql); $row = mysql_fetch_array($r); echo mysql_error(); if ($row['statusEstudio'] == 'standby') { echo '<input name="modificar" type="submit" id="modificar" value="Aplicar" />'; } }
/** @brief update query @ingroup mdl @param $sql sql-query */ function mdl_update_query($sql) { $result = mysql_db_query($this->dbname, $sql, $this->conn); if (mysql_errno() == 0) { $error = ""; $lastId = mysql_insert_id($this->conn); } else { die('In den folgendem Sql-Statement ist ein Fehler aufgetreten: ' . $sql . '<BR><BR>Fehler:' . mysql_error()); } }
public function getBrokerNameById($broker_id) { $funmallDB = $this->load->database("funmall", True); $conn = mysql_connect($funmallDB->hostname, $funmallDB->username, $funmallDB->password); $sql = "SELECT rel_name FROM `admin` where id = " . $broker_id; $result = mysql_db_query('funmall', $sql, $conn); $row = mysql_fetch_row($result); var_dump($row); return empty($row) ? NULL : $row[0]; }
public function ModulosUsuarios1($url, $escape, $raiz, $usuario, $basedatos) { $checaModuloScript = "Select * From ModulosUsuarios1 WHERE \r\nraiz = '" . $raiz . "'\r\nand\r\nusuario = '" . $usuario . "'"; $resScript = mysql_db_query($basedatos, $checaModuloScript); $resulScripModulo = mysql_fetch_array($resScript); echo mysql_error(); if ($resulScripModulo['usuario']) { echo $url . $escape; } }
function QueryDb($query) { error_reporting(0); $result = mysql_db_query($this->database_name, $query, $this->dbid); if ($result == FALSE) { echo "Errore nella query : " . $query; } error_reporting(E_ALL); return $result; }
function getContacts() { global $dbName; $res = mysql_db_query($dbName, "SELECT callsign, locator FROM log ORDER BY id DESC") or die ("Error getting log entries"); // List backwards so we can count off first ten fordifferent colour pin $i = 0; $contacts = array(); while ($arr = mysql_fetch_array($res)) { $contacts[$arr[0]] = $arr[1]; } return $contacts; }
function verifyIfRowExists($tableName, $columnName, $rowValue) { $query = "SELECT * FROM {$tableName} WHERE {$columnName} = \"{$rowValue}\""; $this->connect(); mysql_db_query($this->database, $query) or die("Invalid query:" . $query); if (mysql_affected_rows()) { return true; } else { return false; } }
function guarda($a, $localhost, $user, $passwd, $bd) { //obtener las respuestas de la tabla cuestionario de cada pregunta $connection = mysql_connect($localhost, $user, $passwd) or die("Unable to connect!"); $query = "{$a}"; $result = mysql_db_query($bd, $query, $connection) or die("Error in query: {$query}. " . mysql_error()); //list($a) = mysql_fetch_row($result); mysql_close($connection); //echo "$query $a <br>"; return $a; }
function db_get_unreviewed($language, $category, $fast = 99, $namespace = 0) { //global $mysql_con; if (!isset($mysql_con)) { $mysql_con = set_up_db($language); } make_db_safe($category); $sql = "SELECT page_id,page_title,page_latest,fp_stable, rev_len\n FROM page,categorylinks,flaggedpages, revision\n WHERE cl_to=\"{$category}\" AND cl_from=page_id AND fp_page_id=page_id \n AND page_latest<>fp_stable AND page_namespace={$namespace}\n AND rev_id=page_latest"; $db = $language . 'wiki_p'; $res = mysql_db_query($db, $sql, $mysql_con); $reviewed_pages = array(); while ($o = mysql_fetch_object($res)) { $latest_size = $o->rev_len; $current_rev = $o->page_latest; $stable_rev = $o->fp_stable; if ($stable_rev >= $current_rev) { // something is wrong here, lets leave print "<br/>Something is wrong here with "; print $o->page_title; print " <br/>"; continue; } if ($fast == 1) { $reviewed_pages[$o->page_id] = array('title' => $o->page_title, 'stable_id' => $stable_rev); continue; } //now get the len of the last stable $sql = "SELECT rev_len FROM revision WHERE rev_id={$stable_rev}"; $res_inner = mysql_db_query($db, $sql, $mysql_con); $o3 = mysql_fetch_object($res_inner); $size_diff = $latest_size - $o3->rev_len; if ($fast == 2) { $reviewed_pages[$o->page_id] = array('title' => $o->page_title, 'diff' => $size_diff, 'stable_id' => $stable_rev); continue; } //now get the first unflagged revision while ($current_rev != $stable_rev) { //$before_current_rev = $current_rev; $sql = "SELECT rev_parent_id, rev_timestamp FROM revision \n WHERE rev_id={$current_rev}"; $res_inner = mysql_db_query($db, $sql, $mysql_con); $o2 = mysql_fetch_object($res_inner); $current_rev = $o2->rev_parent_id; if ($current_rev == 0) { break; } if (!$o2) { break; } } $first_unflagged_timestamp = $o2->rev_timestamp; $reviewed_pages[$o->page_id] = array('title' => $o->page_title, 'timestamp' => $first_unflagged_timestamp, 'diff' => $size_diff, 'stable_id' => $stable_rev); } return $reviewed_pages; }
public static function valida($codModulo, $codSM, $usuario, $basedatos) { $checaModuloScript = "Select * From usuariosSubmodulos WHERE codModulo='" . $codModulo . "' \r\nand codSM = '" . $codSM . "' and \r\nusuario1 = '" . $usuario . "'"; $resScript = mysql_db_query($basedatos, $checaModuloScript); $resulScripModulo = mysql_fetch_array($resScript); if ($resulScripModulo['usuario']) { return true; } else { return false; } }
function SQL_ExecSQLsInsert($sql) { global $conn, $db; if (!($res = mysql_db_query($db, $sql))) { echo mysql_error(); exit; } //$affect_rows = mysql_affected_rows($conn); //mysql_close($conn); return mysql_insert_id(); }
/** * connect to database * @param none */ static function connect() { global $dbname; global $hostname; global $username; global $password; //mysql_connect(v::getConfig('db/host'), v::getConfig('db/user'), v::getConfig('db/password')) or //die(v::getI18n('mysql_connect_faild')); mysql_connect($hostname, $username, $password) or die(v::getI18n('mysql_connect_faild')); $result = mysql_db_query($dbname, "SET CHARACTER SET utf8"); }