PHP modified to do not need to login to query, code Confidential

Source: Internet
Author: User
I do not understand PHP, now query needs to log in and then query, I would like to change to do not need to log on can be queried do not know whether to change my post this paragraph, please see friends, thank you,!

Session_Start ();
error_reporting (0);
Header ("content-type:text/html; Charset=utf-8 ");
Require "config.php";
@date_default_timezone_set (PRC);
Set_time_limit (0);
@ob_end_clean ();
Ob_implicit_flush (TRUE);
Switch ($_get[' act ']) {
Case "Database":
if (Empty ($_session[' member ')) {
Exit (' var database=new Array ("login");
}
$connect _db = mysql_connect ($dbnhost, $dbnuser, $dbnpass);
$select _db = mysql_select_db ($dbname, $connect _db);
mysql_query ("SET NAMES ' UTF8 '");
mysql_query ("Set CHARACTER set UTF8");
mysql_query ("SET Character_set_results=utf8");
$rs = mysql_query ("SHOW TABLES from $dbname");
$tables = Array ();
while ($row = Mysql_fetch_row ($rs)) {
$tables [] = $row [0];
}
Mysql_free_result ($RS);
$array _tj=count ($tables);
$count = 1;
$text = "";
foreach ($tables as $key = = $tableName) {
if ($key ==count ($tables)-1) {
$dian = "";
}else{
$dian = ",";
}
$text = $text. ' ". $tableName. ' ". $dian;
$count + +;
}

echo "var database = new Array ($text);";
Break
Case "SELECT":
if (Empty ($_session[' member ')) {
echo "cnrv_msg (\" Please login \ "), AddRow (\" Query after login \ ", \" query after login \ ", \" query after login \ ", \" login query \ ");
Exit

}
$select _act= (int) addslashes (Trim ($_post[' select_act '));
$match _act= (int) addslashes (Trim ($_post[' match_act '));
$key =addslashes (Trim ($_post[' key '));
$table =addslashes (Trim ($_post[' table '));
if (Empty ($key) | | $key = = ") {exit (" Please enter query content ");}
if (strlen ($key) <4) {exit ("Key length!!!");}

$key = Str_replace ("_", "\_", $key);
$key = str_replace ("%", "\%", $key);
Switch ($match _act) {
Case 2: $key = ' =\ '. $key. ' ";";
Case 1: $key = "like \". $key. '%\ '; Break
Default:exit ("SB");
}
Switch ($select _act) {//Query method
Case 1: $limits = "username". $key;
Case 2: $limits = "email". $key;
Case 3: $limits = "username". $key. " or email ". $key; break;
Default:exit ("SB");
}
$connect _db = mysql_connect ($dbnhost, $dbnuser, $dbnpass);
$select _db = mysql_select_db ($dbname, $connect _db);
mysql_query ("SET NAMES ' UTF8 '");
mysql_query ("Set CHARACTER set UTF8");
mysql_query ("SET Character_set_results=utf8");
$sql = "Select $Field from ' $table ' where $limits LIMIT 30";
Require "database.php";
$databasename =database ($table);
if ($result =mysql_query ($sql)) {
while ($rows =mysql_fetch_assoc ($result)) {
$username = mysql_real_escape_string ($rows [' username ']);
$email = mysql_real_escape_string ($rows [' email ']);
$password = mysql_real_escape_string ($rows [' Password ']);
echo "AddRow (\" $username \ ", \" $email \ ", \" $password \ ", \" $databasename \ ");
}//End While
}




Break
Default:print_r ("SB");
}


Reply to discussion (solution)

Remove
if (Empty ($_session[' member ')) {
echo "cnrv_msg (\" Please login \ "), AddRow (\" Query after login \ ", \" query after login \ ", \" query after login \ ", \" login query \ ");
Exit

}

Oh, no. Get rid of this hint box. However, the results of the query are not:

if (Empty ($_session[' member ')) {
Exit (' var database=new Array ("login");
}
if (Empty ($_session[' member ')) {
echo "cnrv_msg (\" Please login \ "), AddRow (\" Query after login \ ", \" query after login \ ", \" query after login \ ", \" login query \ ");
Exit

}
Try this out.

The same. is not the result.

Thank you two bit!! I did not refresh, now good!

You choose a login can check the address to re-login. Does not show the result estimate is a parameter problem

0.0, long time no see mysql_ function.
Remove

13:if (Empty ($_session[' member ')) {     exit (' var database=new Array ("Login");} 47:if (Empty ($_session[' member ')) {        echo "cnrv_msg (\" Please log in \ "), AddRow (\" Log in after query \ ", \" log in after query \ ", \" Log on after query \ ", \" login query \ ");";        Exit }78: $Field variable does not exist, SQL statement error, you can print SQL statements, should be incorrect, query results, or paste the error code
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.