Jump to content

Problem With Comment Page :( !


Faks

Recommended Posts

Hi all i hope to find cure to my problems  :D

here is code of comment link

<a href='/blogs/?page=comment&id=".$row['id']."'>Comment</a> 

here is code of whole comment page http://paste.php.lv/4c30d2286cdd7334d856ce966abc618f?lang=php

And here is Pictures what's is going on on website....

Here is my main issue there are 3 comment's and they all well make such mess ....

mfbrprtx89nfgsqybxk_thumb.jpg

and if there aren't any comment's have such issue ....

c4gik4cu3fj72f7h0qwo_thumb.jpg

Link to comment
https://forums.phpfreaks.com/topic/215349-problem-with-comment-page/
Share on other sites

http://faksx.sytes.net/blogs

check the website news then click the comment

i don't know how to explain image there must be Title and news text but instead i got 3 comments with same information again and again .

good example is http://www.phpfreaks.com/blog/announcing-php-freaks-live-chat

Im guessing this is what your talking about:

http://faksx.sytes.net/blogs/?page=comment&id=2

 

I get this error when trying to submit a comment: Incorrect integer value: '' for column 'news_id' at row 1

 

looking at:

 

$insert = sprintf("INSERT INTO comment (comment_name,comment_datetime,comment_text,news_id,comment_ip) VALUES ('%s',now(),'%s','%s','$ip')",$name,$text,$nid);

 

it looks like your inserting $text into the field news_id which only accepts int values. Where $text is my comment.

Try this:

 

$insert = "INSERT INTO comment (comment_name,comment_datetime,comment_text,news_id,comment_ip) VALUES ('".$name."',".now().",'".$text."','".$nid."','".$ip."')";

 

 

ain't working got error

Fatal error: Call to undefined function now() in F:\My Documents\Websites Backup,Testing Tools,Projects\wnmp\nginx\htdocs\blogs\body_1_view.php on line 37

now() is a MySQL function. Leave it quoted, not un-quoted...

 

('".$name."', NOW() ,'".$text."'... etc.

just like i tout :D but now again i am stuck with news_id ( Incorrect integer value: '' for column 'news_id' at row 1)

i know it cause it is INT and it will accept numbers only part how to figure it out form post id of news inside database i could guess $_POST['id'] directly in mysql ?

Here's whole code of page ....

1.I need fix from top in those pictures those issues or bugs for comment section ....

2.Fix Comment Posting Issue inside INT Table news_id

To see in action all problems visit

http://faksx.sytes.net/blogs/

 

<?php
#if(!$_SESSION['logged_in'] or $_SESSION['u_level'] >= 2 xor 5 xor !$_SESSION['u_level'] > 1) {

#die ('<p><h2><center>Lūdzu Autorezejaties </center></h2>');
#}else
#{
    
    $id = isset ($_REQUEST['id']) ? abs(intval($_REQUEST['id'])) : false;  
    $page = isset ($_GET['start']) ? trim($_GET['page']) : false;
    #$id = $_GET['id'];
    #$id = (isset ($_GET['id']) ? abs(intval ($_GET['id']));
    @mysqlutf8();
    #$news_select = ("SELECT news.id,news_title,news_text , comment .* FROM news, comment WHERE comment.news_id = '$id'; ");
    $news_select = ("SELECT `id`,`news_id` AS `c`,(SELECT `news_text` FROM `news` WHERE `id`=`c`) AS `news_teksts`,(SELECT `news_title` FROM `news` WHERE `id`=`c`) AS `news_title`,`comment_name`,`comment_text`,`comment_datetime` FROM comment WHERE `news_id`= '$id'; ");
    #$comment_select = ("SELECT comment_name,comment_datetime,comment_text FROM comment"); // 2
    $new_result = mysql_query($news_select) or die(mysql_error());
    #$comment_result = mysql_query($comment_select) or die(mysql_error()); // 2
    while ($news = mysql_fetch_array($new_result))
    #while ($comment = mysql_fetch_array($comment_result)) // 2


echo '<h2>'.$news[news_title].'</h2>'.'<br>'.$news[news_teksts].'<br><h2>Komentāri</h2><br>'."<strong><span style='font-size: 11px;color:green;'>".$news[comment_name].' '.$news[comment_datetime].'</span></strong>'.'</h3>'.'<br><br><strong>'.$news[comment_text].'</strong><p>';


if (isset($_POST['pievienot']))
{
    $name = mysql_real_escape_string($_POST[name]);
    $text = mysql_real_escape_string($_POST[text]);
    $nid  = mysql_real_escape_string($_POST[nid]);
    $name = htmlentities($_POST[name]);
    $text = htmlentities($_POST[text]);
    $nid  = htmlentities($_POST[$nid]);

     
    //news_id si ir problema kura moka iznak kad ieliek komentaru vins liek zem noteikta cipara  pat nezinu ko izdomat .
    #$insert = sprintf("INSERT INTO comment (comment_name,comment_datetime,comment_text,news_id,comment_ip) VALUES ('%s',now(),'%s','2','$ip')",$name,$text,$nid);
    $insert = "INSERT INTO comment (comment_name,comment_datetime,comment_text,news_id,comment_ip) VALUES ('".$name."',NOW(),'".$text."','".$nid."','".$ip."')";
    mysql_query($insert) or die(mysql_error());
}


#}

?>

<h3>Pievienot Komentāru</h3>
<form method="post">
Vards : <br><input type="text" name="name" /><br>
Komentara Teksts : <br><textarea name="text" cols="40" rows="6"></textarea><br>
<input type="hidden" type="text" name="nid" value="<?php $id;?>">
<input type="submit"  name="pievienot" value="pievienot" />
</form>

Error message When Click Submit (Incorrect integer value: '' for column 'news_id' at row 1)

Comment posting problem resolved but now left only to resolve the comment page issues .

 

All These issues are related to all comment's not only shown in pictures .

 

Here is example of my problem there are 3 comment authors and each of them have own title and news text but instead i need News Title And Text and under all this

Author of comment,date good example were http://www.phpfreaks.com/blog/announcing-php-freaks-live-chat  how it should look like .

mfbrprtx89nfgsqybxk.jpg

Here is example of comment page without comment's yet it shows a white blank but instead it should show news title and text if there is a comment it appears ....

c4gik4cu3fj72f7h0qwo.jpg

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.