我写了这个脚本,你去 localhost/censor.php/query 看看它是否被占用。这是代码:
<?php
function curPageURL() {
$pageURL = 'http';
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80")
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
else
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
return $pageURL;
}
$test = curPageURL();
$test = str_replace('http://localhost/censor.php/',"",$test);
$con = mysqli_connect("localhost","root","creepers2","spider");
if (mysqli_connect_errno())
echo "Failed to connect to MySQL: " . mysqli_connect_error();
$usname = null;
$result = mysqli_query($con, "SELECT * FROM main WHERE urls='$test'");
while($row = mysqli_fetch_array($result) or die(mysqli_error($con))) {
$usname = $row['urls'];
if ($usname=$test)
echo "Taken!";
else
echo"YEAH!";
}
mysqli_close($con);
?>
如果您访问 localhost/censor.php/queryinthedatabase,它会打印出来。但是,如果您访问 localhost/censor.php/querynotinthedatabase,它不会打印任何内容。请帮忙?