我的 SQL 有问题。例如,我有链接http://www.site.com/single_video.php?id=96&kategorija=fails
在该页面中有两列,一列用于显示该视频,另一列用于相关视频。但是如果用户在链接中添加 ',它将在“相关视频”列中不显示任何内容。所以我试图过滤掉“有效” “类别..但不知何故它不起作用..这是我的代码......
<?php
include 'includes/connect_video_index.php';
mysql_query("SET NAMES utf8"); //recimo bazi da postoje čak i hrvatska slova :D
$result1 = mysql_query('SELECT *
FROM video
WHERE id!="'.$id1.'"
AND kategorija="'.$escaped_cat.'"
ORDER BY RAND()
LIMIT 10', $con1);
while ($row1 = mysql_fetch_array($result1)){
$kat = $_GET['kategorija'];
$kategorija = mysql_real_escape_string($kat);
if ($kategorija == $row1['kategorija']){
echo 'This category exists'; //this part is working
} else {
//this part doesn't works when I enter blah blah, or whatever :S
echo "This category doesnt' exist";
}
}