Jump to content

the id in my blog code not working


mistari

Recommended Posts

Here is the work in progress:

 

http://www.mistari.com

 

the id does not display in the url on the add comment page:

 

"http://www.mistari.com/addcomments.php?id="

 

addcomments.php:

 

<?php

include('header.inc');

xxxx

$action = strip_tags($_GET["action"]);
$id = strip_tags($_GET["id"]);

if ($action=="add")
{
    $name = strip_tags($_POST["name"]);
    $entry = strip_tags($_POST["entry"]);
    $email = strip_tags($_POST["email"]);
    
    // add comments
    if (empty($name) || empty($entry))
    {
        die ("Error, you cannot submit a blank entry.");
    }
    
    $q = "insert into blog_comments (name, email, date, blog_id, entry) VALUES ('$name','$email',now(),'$id','$entry')";
    $result= mysql_query($q) or die 
    ("Could not execute query : $q." . mysql_error());    
    if ($result)
    {
        echo "Comment has been added. Thanks nukka.";
        echo "<p>Click <a href=\"readcomments.php?id=$id\">here</a> to read.</p>";
        
    }
    
}
else {


?>

<form action="addcomments.php?action=add&id=<?php echo $blog_id;?>" method="post">
<table width="130" border="0" cellspacing="1" cellpadding="0">
<tr> 
<td height="23" colspan="2"><b>Add Comment</b></td>
</tr>
<tr> 
<td>Name:*</td>
<td> 
<input type="text" name="name" size="30">
</td>
</tr>
<tr> 
<td height="25">Email:</td>
<td height="25"> 
<input type="text" name="email" size="30">
</td>
</tr>
<tr>
<td height="25">Comments:*</td>
<td height="25">
<textarea name="entry" cols="30" rows="5"></textarea>
</td>
</tr>
<tr><td colspan=2><input type="submit" value="submit"></td></tr>
</table></form>
<?php
}

include('footer.inc');

?> 

 

readcomments.php:

 

<?php

include('header.inc');

xxxx

$id = strip_tags($_GET["id"]);

$q = "SELECT * from blog_comments where blog_id='$id' order by date desc ";
$result= mysql_query($q) or die
("Could not execute query : $q." . mysql_error());


while ($row=mysql_fetch_array($result))
{
$id=$row["id"];
$name=$row["name"];
$email=$row["email"];
$entry=$row["entry"];
$date=$row["date"];
$blog_id = $row["blog_id"];

?>

<table width="80%" border="0" cellspacing="1" cellpadding="0" align="center">
<tr>
<td>Comments for <?php echo "$title"; ?></td>
</tr>
<tr>
<td>
<?php echo "$entry"; ?>
<p>Posted by <a href="mailto:<?php echo "$email"; ?>"><?php echo "$name"; ?> on <?php echo "$date"; ?>.</p>
</td>
</tr>
</table>

<?php
}

// display write comments HTML here.
?><p align="center"><a href="<?php echo "addcomments.php?id=$blog_id"; ?>">Add Comments</a></p>

<?php
include('footer.inc');
?>

 

someone help me? this is driving me nuts! and i know its something really small!!

Link to comment
Share on other sites

lol. HAI!!!

 

here's all the database entries.

 

Full Texts  id name email date blog_id entry

Edit Delete 25 hello   2008-01-28 18:46:13 4 sfdfssfd

Edit Delete 24 test2   2008-01-28 18:44:40 23 testing again

Edit Delete 23 tester   2008-01-28 18:44:26 4 testing

Edit Delete 22 hello   2008-01-28 18:41:37 0 HAI MISTARI.

Edit Delete 20 Joe   2008-01-28 18:39:59 0 test

Edit Delete 21 joe   2008-01-28 18:40:13 0 test

Edit Delete 26 marcus   2008-01-28 18:49:12 23 HOLA.

Edit Delete 27 test again   2008-01-28 18:49:40 23 again..

 

where's it getting these numbers from???

Link to comment
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.