I am working on the add_comment function and I have a slight issue I don't know how to solve. Here is the function I want to use:
function add_comment($name, $author, $email, $body) { if(valid_post($name) == false){ return false; } $name = mysql_real_escape_string(htmlentities($name)); $author = mysql_real_escape_string(htmlentities($author)); $email = mysql_real_escape_string(htmlentities($email)); $body = mysql_real_escape_string(nl2br(htmlentities($body))); mysql_query("INSERT INTO `comments` (`com_post_id`, `com_author`, `com_author_email`, `com_body`, `com_date`) VALUES ('$name', '$author', '$email', '$body', NOW())"); return true; }I am getting the post by its name and not the id. I need to match `com_post_id` with the `posts`.`id` but I have $name (`post_name`) available. I checked WordPress to see how the commenting is handled but it looks too complicated. The reason I am getting posts by $name is that I want nice looking urls such as http://www.mysite.com/this-is-a-post, and here post_name = this-is-a-post.