PHP help! Immediate 10 pts to best answer!?

  • Thread starter Thread starter skinnypspplayer
  • Start date Start date
S

skinnypspplayer

Guest
Alright, I have a MySQL database with a comments table. All I'm trying to do is to show any certain comments' ID number on a different page. Here's page with comments (scroll down):

http://www.kingps3.com/_r3.php

Now if you were to be an admin at the site you would see a link below each comment saying 'Comment ID'. All I want to be able to do is to click that and have it link to a diff. page (commentID.php) and show that certain comments' ID number. I put the link to the commentID.php page (below each comment) as:

<a href="commentID.php?$cid='.$info2->id.'"... ID</a>

So I want '$info2->id' to equal '$cid' but its not working. '$info2->id' works fine on the page with the comments but when I try to make it equal on the commentID.php page, it doesn't work. Here's the commentID.php page:

<?php include('session.php');?>
<?php
$res = mysql_query("SELECT * FROM comments WHERE id='$cid'");
while ($rec = mysql_fetch_array($res)){
echo $rec[id];
}
?>

So to explain the above code, it goes like this. I click the 'Comment ID' link on the page with the comments which takes me to 'commentID.php?$cid='.$info2->id.'. If I look on the address bar after clicking the link I can see that $info2->id works because it will say for instance 107 (the comment's ID). But for some reason, it won't make it equal to $cid. So on commentID.php, when I try to pull up the ID of the selected comment, it doesn't show anything.

Any help? Ask if you need more information (say what you need) and I'll add more details. Thanks!
 
I think the problem is on this line:

echo $rec[id];

try this instead:

echo $rec['id'];

> Also, try removing the single quotes from around the $cid in your select statement...so, like this:

$res = mysql_query("SELECT * FROM comments WHERE id=$cid");
 
Back
Top