Jump to content

Recommended Posts

The problem is whit the var $threadid .

It dosent work here(it dosen't display the data from database):  $dbh = "SELECT *FROM comments WHERE threadid = '".$threadid."' ";

But if I assign a value before the that code the html page show correctly.

 

 

include("config.php");

$name = $_POST['name'];
$comment = $_POST['comment'];
$threadid = $_POST['threadid'];

if($name & $comment)
{
	$dbh="INSERT INTO comments (name,comment,threadid) VALUES ('$name','$comment','$threadid') ";
	mysql_query($dbh);


}



  
    
    $dbh = "SELECT *FROM comments WHERE threadid = '".$threadid."' ";
    $req = mysql_query($dbh);
    while($row=mysql_fetch_array($req))
    {
         echo "<li>";
        echo "<br>"."<b>".$row['name']."</b></br>"."<br>".$row['comment']."</br>";
	echo "</li>";
    }

 

$('.submit').click(function(){
		  location.reload();
		var name = $("#name").val();
            var comment = $("#comment").val();


	var threadid  = $("#v").val();

		var dat = 'name='+name+'&comment='+comment+'&threadid='+threadid;

            $.ajax({
			type:"post",
		    url:"comment.php",
			data:dat,
			success:function(){ 
			console.log("dat"); 
			 }
	      });
              
		 return false;

	 });

Link to comment
https://forums.phpfreaks.com/topic/259821-php-problem/
Share on other sites

what exactly is it doing?

 

are you getting empty list items? or nothing at all that is within the mysql loop?

 

if you aren't even getting the empty list items sent to the browser, then it would appear that nothing in the comments database matches the threadid you are supplying?

Link to comment
https://forums.phpfreaks.com/topic/259821-php-problem/#findComment-1331989
Share on other sites

Well when i submit a comment in the html page the PHP code insert correctly in the database but fails at SELECT * FROM

And also if i manually assign a value to $threadid right before the second query for example 2 in the html page the value from database appear correctly:

 

Without assigned value (Not displaying correctly): http://s17.postimage.org/c1ldbk6gf/example1.png

With assigned value(Displaying correctly):http://s17.postimage.org/8knwmbwrz/example2.png

Link to comment
https://forums.phpfreaks.com/topic/259821-php-problem/#findComment-1331997
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.