热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

回应论坛ID到新页面显示内容?-EchoingforumIdtonewpagetodisplaycontent?

cansomeonepleasehelpmeiamhavingproblemscreatingmyforum.有人请帮助我,我在创建论坛时遇到问题。Atthemomen

can someone please help me i am having problems creating my forum.

有人请帮助我,我在创建论坛时遇到问题。

At the moment users can create posts, the post title is listed down the page and then the user is suppose to be able to click the title link and be taken to read_post.php and then this should take the user to another page where the post content can be viewed, i am trying to do this by echoing the forum post id but it doesnt seem to want to work, instead i get this error:

目前用户可以创建帖子,帖子标题列在页面下方,然后用户可以点击标题链接并被带到read_post.php然后这应该将用户带到另一个页面的帖子内容可以查看,我试图通过回应论坛帖子ID来做到这一点但它似乎不想工作,而是我得到这个错误:

Database query failed: 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 3

can someonee please show me where im going wrong.

有人可以告诉我哪里出错了。

here is my sql function:

这是我的sql函数:

function read_forum() {
            global $connection;
            global $forum_id;
            $query = "SELECT *
                        FROM ptb_forum, ptb_profiles
                        WHERE ptb_forum.id = $forum_id ";
            $forum_set = mysql_query($query, $connection);
            confirm_query($forum_set);
            return $forum_set;
        }  

here is the link code that takes the user to read_post.php which suppose to echo the forum id and display the content for each individual post.

这是将用户带到read_post.php的链接代码,它假设回显论坛ID并显示每个帖子的内容。




            
{$forum['title']} - Posted by {$user['first_name']}"; ?>
here's my code for read_post.php:
Messages Between & You




";?>





"; ?>
Conversations between you and {$forum['display_name']}.
"; ?>
Message Subject: {$forum['subject']}"; ?>



Message:

{$forum['content']}"; ?>



1 个解决方案

#1


0  

You have an error in your query... Your parameter is not quoted...

您的查询中有错误...您的参数未被引用...

 $query = "SELECT *
     FROM ptb_forum, ptb_profiles
     WHERE ptb_forum.id = '$forum_id'";

However... I suggest that you refrain from using the mysql_ family of functions. They are deprecated and due to be removed from PHP in a future release. You should be using parameterized queries using MySQLi or PDO.

但是......我建议你不要使用mysql_系列函数。它们已被弃用,并将在未来版本中从PHP中删除。您应该使用MySQLi或PDO使用参数化查询。

Also, global is evil. I've never had a need to use it in 10 years of PHP programming. Neither should you.

全球也是邪恶的。我从来没有需要在10年的PHP编程中使用它。你也不应该。


推荐阅读
author-avatar
Duanzd09
这个家伙很懒,什么也没留下!
Tags | 热门标签
RankList | 热门文章
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有