function storeData($sql, $eMore) { $eMore = ""; $hn = 'localhost'; $user = '******'; $pw = 'password123'; $cn = MySQL_connect($hn, $user, $pw); if ($cn) { $dbname = 'advocacy_db'; $connect = MySQL_select_db($dbname); if ($connect) { $return = MySQL_query($sql, $cn); if ($return == TRUE) { //success... } else { $eMore .= "Query (return) was not successful.\n"; //error... } MySQL_close($cn); } else { $eMore .= "DB selection was not successful.\n"; } } else { $eMore .= "Connection to db was not successful.\n"; } return $eMore; }
/** connect to database using $mysql_info array * possibly should be replaced with PEAR equivalent */ public static function connect( $mysql_info ) { $server = $mysql_info["server"]; $user = $mysql_info["user"]; $password = $mysql_info["password"]; $dbname = $mysql_info["dbname"]; $connection = MySQL_connect( $server, $user, $password ); if ( !$connection )die( "Cannot connect to SQL server. Try again later." ); MySQL_select_db( $dbname ) or die( "Cannot open database" ); mysql_query( "SET NAMES 'utf8'" ); }
function connect() { $server = "localhost"; $user = "******"; $password = ""; $dbname = "trainer"; $connection = MySQL_connect( $server, $user, $password ); if ( !$connection )die( "Cannot connect to SQL server. Try again later." ); MySQL_select_db( $dbname ) or die( "Cannot open database" ); mysql_query( "SET NAMES 'utf8'" ); }
function connect() { global $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname; $db1 = $wgDBserver; # hostname $db2 = $wgDBuser; # user $db3 = $wgDBpassword; # pass $db4 = $wgDBname; # db-name $connection = MySQL_connect( $db1, $db2, $db3 ); if ( !$connection )die( "Cannot connect to SQL server. Try again later." ); MySQL_select_db( $db4 ) or die( "Cannot open database" ); mysql_query( "SET NAMES 'utf8'" ); }
<?php header( "Content-type: text/html; charset=UTF-8" ); $dc = "umls"; define( 'MEDIAWIKI', true ); include_once( "../../../../LocalSettings.php" ); global $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname; $db1 = $wgDBserver; # hostname $db2 = $wgDBuser; # user $db3 = $wgDBpassword; # pass $db4 = $wgDBname; # db-name $connection = MySQL_connect( $db1, $db2, $db3 ); if ( !$connection )die( "Cannot connect to SQL server. Try again later." ); MySQL_select_db( $db4 ) or die( "Cannot open database" ); mysql_query( "SET NAMES 'utf8'" ); echo " <style type=\"text/css\"><!-- body {font-family:arial,sans-serif} --></style> "; function stopwatch() { list( $usec, $sec ) = explode( " ", microtime() ); return ( (float)$usec + (float)$sec ); } /* $result = mysql_query("SELECT
<?php $userid = $_GET['userid']; $btype = $_GET['btype']; $dbs = MySQL_connect("192.168.234.129", "toryzen", "q1w2e3r4"); MySQL_select_db("qqnotic", $dbs); mysql_query("set names utf8"); $now = time(); if ($userid && $btype) { $sql1 = "INSERT INTO qqnotic VALUES ('NULL','{$btype}','{$userid}','',0,'{$now}',0)"; $result = MySQL_query($sql1); echo "ok"; } else { echo "erro"; } mysql_close($dbs);