Jump to content

problem with SELECT


kleb

Recommended Posts

I've re-done you're reply.php file.

 

You will need to add a new input to your form that posts the reply message something like this:

 <input type="hidden" name="topicsID" value="<?PHP echo intVal($_GET['id']);?>"> 

 

Then change your reply.php file to the following, which will add the "topicsID" to the database so you know which topic the comment was posted for.

 

<?PHP

  include"header.php";

  if($_SERVER['REQUEST_METHOD'] == 'POST') {

    $topicsID = intVal($_POST['topicsID']);
    $comment = mysql_real_escape_string(trim($_POST['comment']));
    $name    = mysql_real_escape_string(trim($_POST['name']));

    if($comment!=='' && $name!=='' && $topicID != 0) {
      $ins="INSERT INTO `post` (`topicsID`,`post_content`,`post_by`)VALUES({$topicsID}, '{$comment}','{$name}')";
      mysql_query($ins) or die(mysql_error());

      if(mysql_affected_rows()) {
        echo"succesfull, you can click back to view your comment and other new comments";
      } else {
        echo"You can not post an empty page or leave your name blank";
    }
  }

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.