PHP implementation of the MySQL General query program _php instance

Source: Internet
Author: User
if (GET_MAGIC_QUOTES_GPC () ==1) {
?>
<body>
Note that this program needs to have the PHP configuration file (PHP3 PHP3.INI,PHP4 as PHP.ini) in the MAGIC_QUOTES_GPC
Set to OFF or 0, please reboot Apache after modification.
</body>
?
Exit ();
}
Set_magic_quotes_runtime (0);
$host = ' localhost ';
$db = ' Test ';
$user = ' Test ';
$pass = ';
[php/inc/str2url.php] CVS 1.2
function Str2url ($path) {
Return Eregi_replace ("%2f", "/", UrlEncode ($path));
}
?>
<body>
<form action= "<?echo str2url ($PHP _self);? > "method=" Post >
Please enter the SQL statement:<br>
<textarea name= "SQL" cols= "rows=" 5 "><?echo $sql;? ></textarea><br>
<input type= "Submit" name= "cmd" value= "Query" >
<input type= "Submit" name= "cmd" value= "Executive" >
</form>
?
if ($cmd) {
$con = Mysql_pconnect ($host, $user, $pass) or die (' Unable to connect '. $host. ' Server ');
mysql_select_db ($db, $con) or Die (' Cannot connect '. $db. ' database ');
$rst = mysql_query ($sql, $con) or Die ($sql. ' Error ');
if ($cmd = = ' query ') {
$num _fields = Mysql_num_fields ($rst);
Echo ' Echo ' <table border= "1" cellpadding= "0" cellspacing= "0" > ";
Echo ' <caption align= ' center > '. $sql. ' </option> ';
Echo ' <tr> ';
For ($i =0 $i < $num _fields $i + +) echo ' <th> '. Mysql_field_name ($rst, $i). ' </th> ';
Echo ' </tr> ';
while ($row =mysql_fetch_row ($rst)) {
Echo ' <tr> ';
For ($i =0 $i < $num _fields $i + +) echo ' <td> '. $row [$i]. ' </td> ';
Echo ' </tr> ';
}
Echo ' </table> ';
Mysql_free_result ($rst);
}
else echo ' has '. Mysql_affected_rows ($con). ' Rows affected ';
}
?>
</body>

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.