I am in the process of developing a forum with PHP and MySQL. I got stuck in a problem that i have never came up with before. The problem occurs when I am invoking a method to edit a forum post.
I have a object class to handle behaviors of a post. And I am trying to make the forum SEO friendly too, therefore I am using Unique URLs to identify posts as a experiment. If I have made security holes, please be kind enough to point them out, too (thank you!).
I will copy only the required parts of the code.
This is where i invoke the method
$url = $_GET['url'];
$posts->editForumPost($heading, $desc, $catetgory, $username, $tags, $url);
And to be sure if its not an array i print_r($url)
which gives me the correct url sent in the address. I am familiar when I print_r
an array, it says that it is an array and gives the indices and their values too. Its not like that in this case.
So in the editForumPost() function I call another function like this
$post = $this->getPostDetails($url);
take note here, that I am using this same function to get the values of the post to print it to display to the user. and I don't have a problem there, But when i call the function inside the editForumPost() function I get a
Array to string conversion in blah blah
I can't think of a reason why this happens. So then again i changed my functions to run in post_ids instead of urls, same problem happens for some reason.
I will post the full code of the functions and invoking places if anyone requests.
EDIT:
public function getPostDetails($url)
{
$query = $this->db->prepare("SELECT `heading`,`post_id`,`category`, `description`, `username`, `category`,`post_time` FROM `forum` WHERE `friendly_url` = ? LIMIT 1");
$query->bindValue(1,$url);
try
{
$query->execute();
}
catch(PDOException $e)
{
die($e->getMessage());
}
return $query->fetch();
}