PHP论坛试图在类别中显示主题的SQL错误 [英] SQL error for PHP forum trying to display topics in a category

查看:102
本文介绍了PHP论坛试图在类别中显示主题的SQL错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个PHP论坛,我试图建立该论坛,并且当用户单击该类别时,我想显示该类别中的所有主题(例如,我的类别可以是足球,其中包含诸如最喜欢的球队,最喜欢的球队"播放器"等.但是,尝试显示主题时遇到了一个非常繁琐的错误,如下所示:

无法显示类别,请稍后再试.检查与您的MySQL服务器版本相对应的手册,以找到在第8行''''附近使用的正确语法

这是我与错误相关的代码:

I have a PHP forum that im trying to build and when the user clicks on the category I want to display all topics in that category (For example my category could be football and that would contain topics such as "favourite team, favourite player" etc. However, I have come across a very tedious error when attempting to display the topics, as seen below:

The category could not be displayed, please try again later.You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '''''' at line 8

This is the code I have that relates to the error:

$sql = "SELECT
            cat_id,
            cat_name,  //this is line 8
            cat_description
        FROM
            categories
        WHERE
            cat_id = " . mysql_real_escape_string($_GET['cat_id']);
 
$result = mysql_query($sql);

推荐答案

sql = " .mysql_real_escape_string(
sql = "SELECT cat_id, cat_name, //this is line 8 cat_description FROM categories WHERE cat_id = " . mysql_real_escape_string(


_GET [ cat_id' ]);
_GET['cat_id']);


结果 = mysql_query(
result = mysql_query(


这篇关于PHP论坛试图在类别中显示主题的SQL错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆