Connect to database : trang này đã được đọc
lần
COPYRIGHT BY MRRO WINDAK UPGRADE
align="center">
CONNECT TO DATABASE align="center">
Upgraded by Windak align="center">Version 2.0 align="center">
//Khoi tao $self=$HTTP_SERVER_VARS['PHP_SELF']; $query=stripslashes($query); echo $query; if (isset($HTTP_POST_VARS['submit']) || isset($HTTP_POST_VARS['select']) || isset($HTTP_POST_VARS['update']) || isset($HTTP_GET_VARS['tb'])) { //Thiet lap Query if (isset($HTTP_GET_VARS['tb'])) { $database=$HTTP_GET_VARS['db']; $username=$HTTP_GET_VARS['user']; $password=$HTTP_GET_VARS['pass']; $server=$HTTP_GET_VARS['server']; $table=$HTTP_GET_VARS['tb']; $query = "Select * from $table"; echo $query; } $conn = mysql_connect("$server","$username","$password"); if (!conn) { echo mysql_error(); exit; } if (isset($HTTP_POST_VARS['select'])) { if (($column2)&&($value2)) { $query="Select $StrColumn from $table where $column2 = '$value2'"; } else $query="Select $StrColumn from $table" ; } else if (isset($HTTP_POST_VARS['update'])) { if (($column2)&&($value2)&&($column1)&&($value1))
{ $query="Update $table set $column1='$value1' where $column2='$value2'"; } else die("PLEASE CORRECT YOUR INPUT"); } //Chay mysql_select_db($database); $res=mysql_query($query); echo "
" ; echo ""; $ncols = mysql_num_fields($res); while($i<$ncols) { $meta = mysql_fetch_field ($res); echo " ". $meta->name ." | " ; $i++; } echo "
"; while($data=mysql_fetch_array($res)) { echo(""); for($i=0; $i<$ncols; $i++) { echo " ". $data[$i] ." | "; } echo("
"); } mysql_free_result($res); } //Click ListDB else if (isset($HTTP_POST_VARS['ListDB'])) { $conn = mysql_connect("$server","$username","$password"); $db_list = mysql_list_dbs($conn); if (!$db_list) { echo mysql_error(); exit; } while ($row = mysql_fetch_object($db_list)) { $rdata = $row->Database ; $tb_list = mysql_list_tables($rdata); if (!$tb_list) { echo "$rdata "; } else echo "$rdata "; }
} else if (isset($HTTP_GET_VARS['db'])) { //Get info $database=$HTTP_GET_VARS['db']; $username=$HTTP_GET_VARS['user']; $password=$HTTP_GET_VARS['pass']; $server=$HTTP_GET_VARS['server']; //Test permission if (!mysql_connect("$server","$username","$password")) { echo mysql_error(); exit; } $tb_list = mysql_list_tables($database); // Okie List while ($row = mysql_fetch_row($tb_list)) { echo "$row[0] "; } mysql_free_result($tb_list); } ?>