【发布时间】:2012-01-13 11:32:11
【问题描述】:
这是一个 mySQL 查询,其密码和用户名被故意搞砸了。它只返回一个结果,除了该结果的今天日期之外,不返回任何其他信息。尝试什么搜索都没有关系。
<?php
$proto = $_GET['p'];
$terms = $_GET['f'];
$return;
if($proto == 'inline'){
echo 'checking';
$username="*******";
$password="*******";
$database="*******";
$my_text = $_GET['f']; //what I'm searching for
$my_category = '8'; //whatever category number it is
mysql_connect(localhost,$username,$password) or die(mysql_error());
mysql_select_db($database) or die(mysql_error());
$result = mysql_query("SELECT ID FROM wp_posts WHERE post_title LIKE '%$my_text%' ");
// select all posts that have your text
while ($row = mysql_fetch_array($result));
$postname = $row['post_name'];
$posttitle = $row['post_title'];
$postID = $row['ID'];
$date = date ( 'd-M-Y' , strtotime($row['post_date']) );
$return.= '
<a href="http://www.robin-knight.com/' . $postname .'">'.$posttitle.' ('.$postname.')<br /><span style="font-size:10px; color:#555;">'.get_the_time("d-M-Y", $postID).' - '.get_post_meta($postID, "status", true).'</span></a>
';
//while have posts
echo $return;
}
?>
【问题讨论】:
-
是时候学习一下 SQL 是如何工作的了,我想...
-
你有什么问题?另外,“没有真正工作”是什么意思?
-
不错的 SQL 注入孔。希望您喜欢有人会在您的数据库中停放的卡车。