SitePoint Sponsor

User Tag List

Results 1 to 12 of 12
  1. #1
    billycundiff{float:left;} silver trophybronze trophy RyanReese's Avatar
    Join Date
    Oct 2008
    Location
    Whiteford, Maryland, United States
    Posts
    13,564
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)

    I'm a helpless litle puppy-easy comment script

    Code:
    <?
    session_start();
    include "config.php";
    //retrieve the main article 
    if(isset($_GET['aid'])){
    $_SESSION['aid']=$_GET['aid'];
    $getarticle="SELECT * FROM article WHERE artid = ".$_GET['aid']." ORDER by date_posted ASC";
    if(!$result = mysql_query($getarticle)){
    echo mysql_error();
    }else{
    $num=mysql_num_rows($result);
    }
    
    
    //retrieve all comments made to this article
    $getcomments="SELECT * FROM article WHERE artchild = ".$_GET['aid']." ORDER by date_posted ASC";
    $getcomments_result = mysql_query($getcomments);
    $comment_num=mysql_num_rows($getcomments_result);
    }
    
    
    if(isset($_POST['theComment'])){
    $query = "INSERT INTO article SET name='".$_POST['name']."',title='".$_POST['theTitle']."',comments='".$_POST['comment']."',";
    $query .="date_posted=NOW(),categoryID='".$_POST['CID']."',artchild='".$_POST['theID']."'";
    if(!mysql_query($query)){
    echo mysql_error();
    }else{
    //getthe aerilvce
    $getarticle="SELECT * FROM article WHERE artid = ".$_SESSION['aid']." ORDER by date_posted ASC";
    if(!$result = mysql_query($getarticle)){
    echo mysql_error();
    }else{
    $num=mysql_num_rows($result);
    }
    }
    //retrieve all comments made to this article
    $getcomments="SELECT * FROM article WHERE artchild = ".$_SESSION['aid']." ORDER by date_posted ASC";
    $getcomments_result = mysql_query($getcomments);
    $comment_num=mysql_num_rows($getcomments_result);
    
    }
    
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>MyBlog::Comments</title>
    <style type="text/css">
    <!--
    .style1 {color: #999999}
    -->
    </style>
    <style type="text/css">
    <!--
    .style2 {color: #CCCCCC}
    -->
    </style>
    <style type="text/css">
    <!--
    .style3 {color: #333333}
    -->
    </style>
    </head>
    
    <body>
    <table width="100%" border="0" cellspacing="1">
      <tr>
        <td colspan="2" class="temptitle">MyBlog</td>
      </tr>
      <tr>
        <td width="74%" valign="top"><!-- InstanceBeginEditable name="EditRegion3" --><table width="100%" border="0" cellspacing="1">
            <tr>
              <td>&nbsp;</td>
            </tr>
    		<?
    		if(isset($num) && ($num > 0)){
    		while($row_article=mysql_fetch_assoc($result)){
    		?>
            <tr>
              <td>&nbsp;</td>
            </tr>
            <tr class="title">
              <td><? $_SESSION['title']=$row_article['title'];
    		  echo $_SESSION['title'];?> </td>
            </tr>
            <tr>
              <td>&nbsp;</td>
            </tr>
            <tr class="tbody">
              <td><?=$row_article['comments'];?> </td>
            </tr>
            <tr>
              <td>&nbsp;</td>
            </tr>
            
            <?
    		}
    		}else{
    		?>
    		<tr>
    		<td><p>Could not find this article.</p>		</td></tr>
    		
          <? }?>
    	  </table>
    	  <br />
    	  <br />
    	  
    	  <table width="100%" border="0" cellspacing="1">
          
    	  <tr>
              <td class="commentsheader">Comments</td>
            </tr>
    	    
            <tr>
              <td>&nbsp;</td>
            </tr>
    		<?
    		if(isset($comment_num) && ($comment_num>0)){
    		while($row_comments=mysql_fetch_assoc($getcomments_result)){
    		?>
            <tr class="tbody">
              <td><?=$row_comments['comments']; ?> </td>
            </tr>
            <tr>
              <td>&nbsp;</td>
            </tr>
            <tr class="comlinks">
              <td>Date posted: <?=$row_comments['date_posted']; ?> | posted by: <?=$row_comments['name']; ?></td>
            </tr>
            <tr class="links">
              <td>&nbsp;</td>
            </tr>
            
    		<?
    		}
    		}else{
    		?>
    		<tr>
    		<td><p>This article does not have any comments.</p>		</td></tr>
    		
          <? }?>
          </table>
    	  <br />
    	
    	  <form action="comments.php?aid=<?=$_SESSION['aid']?>" method="post" name="form1">
    	  <table width="100%" border="0" cellspacing="1">
            <tr class="commentsheader">
              <td width="21%">Post a comment </td>
              <td width="79%">&nbsp;</td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td><span class="style3">Name</span></td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td colspan="2"><input name="name" type="text" class="input" id="name" size="60" />
                <input type="hidden" name="theID" value="<?=$_GET['aid']?>" />
    			 <input type="hidden" name="CID" value="<?=$_GET['cid']?>" />
    		    <input type="hidden" name="theTitle" value="<?=$_SESSION['title'];?>" /></td>
              </tr>
            <tr>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td><span class="style1 style2 style3">Comment</span></td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td colspan="2"><textarea name="comment" cols="60" rows="9" class="input" id="comment"></textarea></td>
              </tr>
            <tr>
              <td colspan="2">&nbsp;</td>
            </tr>
            <tr>
              <td colspan="2"><input name="theComment" type="submit" class="input" id="theComment" value="Post Comment" /></td>
            </tr>
          </table>
    	  
    	  </form>
    	  
    	  <!-- InstanceEndEditable --></td>
        <td width="26%" valign="top"><!-- InstanceBeginEditable name="EditRegion4" --> <table width="100%" border="0" cellspacing="1">
            <tr class="navbot">
              <td bgcolor="#CCCCFF" class="navbot">Recent Topics </td>
            </tr>
    		<tr>
              <td>&nbsp;</td>
            </tr>
    		<?
    		$query="Select *,COUNT(*) FROM article INNER JOIN categories ON categoryID=catid WHERE DATE_SUB(CURDATE(),INTERVAL 30 DAY) GROUP BY title DESC LIMIT 10 ";
    $blog = mysql_query($query) or die(mysql_error());
    $num_blog = mysql_num_rows($blog);
    if($num_blog > 0){
    while($row_blog = mysql_fetch_assoc($blog)){
    		?>
           
            <tr>
              <td class="listtopics"><b><?=$row_blog['title'];?></b> posted in <b><?=$row_blog['category']?></b> </td>
            </tr>
    		<? 
    		}
    		}else{ ?>
    		<tr>
    		<td><p>No topics to list</p></td>
    		</tr>
    		<? } ?>
          </table><!-- InstanceEndEditable --></td>
      </tr>
      <tr>
        <td colspan="2" class="copyright">Copyright&copy;2006</td>
      </tr>
    </table>
    </body>
    <!-- InstanceEnd --></html>
    That's my comment page-comments.php

    config.php just connects to my server...nothing special

    index.php
    Code:
    <?
    include "config.php";
    $query1="Select *,DATE_FORMAT(date_posted,'%W,%d %b %Y') as thedate FROM article INNER JOIN categories ON categoryID=catid WHERE DATE_SUB(CURDATE(),INTERVAL 30 DAY)AND artchild='0' ORDER BY date_posted DESC LIMIT 10 ";
    $blogarticles = mysql_query($query1) or die(mysql_error());
    $num = mysql_num_rows($blogarticles);
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <!-- InstanceBeginEditable name="doctitle" -->
    <title>Blog::</title>
    </head>
    
    <body>
    <table width="100%" border="0" cellspacing="1">
      <tr>
        <td colspan="2" class="temptitle">MyBlog</td>
      </tr>
      <tr>
        <td width="74%" valign="top"><!-- InstanceBeginEditable name="EditRegion3" -->
          <table width="100%" border="0" cellspacing="1">
    	  <tr>
              <td>&nbsp;</td>
            </tr>
    	  <tr>
              <td>&nbsp;</td>
            </tr>
    	  <? 
    	if($num > 0){
    	while($row_articles = mysql_fetch_assoc($blogarticles)){
    	?>
           
               <tr class="title">
              <td><?=$row_articles['title'];?> </td>
            </tr> 
            <tr>
              <td>&nbsp;</td>
            </tr>
            <tr class="tbody">
              <td><?=$row_articles['comments'];?></td>
            </tr>
            <tr>
              <td>&nbsp;</td>
            </tr>
    		
            <tr class="links">
              <td>Date posted: <?=$row_articles['date_posted'];?> | <a href="comments.php?aid=<?=$row_articles['artid'];?>&cid=<?=$row_articles['categoryID'];?>">Comments(<? //echo $row_articles['artid'];		  
    		
    		//$thenum=row_articles['artid'];
    		$getcomments = "SELECT * FROM article WHERE artchild='".$row_articles['artid']."'";
    		if(!$theResult=mysql_query($getcomments)){
    		echo mysql_error();
    		}else{
    		$num_comments=mysql_num_rows($theResult);
    		echo $num_comments;
    		}
    		?>) </a></td>
            </tr>
            <tr class="links">
              <td>&nbsp;</td>
            </tr>
            <tr class="links">
              <td>&nbsp;</td>
            </tr>
    		<?
    		}
    		}else{
    		 ?>
    		<tr><td><p>There are no articles available at present</p></td></tr>
    		<?
    		}
    		?>
    		<tr>		</tr>
          </table>
        <!-- InstanceEndEditable --></td>
        <td width="26%" valign="top"><!-- InstanceBeginEditable name="EditRegion4" -->
    	<br />
          <table width="100%" border="0" cellspacing="1">
            <tr class="navbot">
              <td bgcolor="#CCCCFF" class="navbot">Recent Topics </td>
            </tr>
    		<tr>
              <td>&nbsp;</td>
            </tr>
    		<?
    		$query="Select *,COUNT(*) FROM article INNER JOIN categories ON categoryID=catid WHERE DATE_SUB(CURDATE(),INTERVAL 30 DAY) GROUP BY title DESC LIMIT 10 ";
    $blog = mysql_query($query) or die(mysql_error());
    $num_blog = mysql_num_rows($blog);
    if($num_blog > 0){
    while($row_blog = mysql_fetch_assoc($blog)){
    		?>
           
            <tr>
              <td class="listtopics"><b><?=$row_blog['title'];?></b> posted in <b><?=$row_blog['category']?></b> </td>
            </tr>
    		<? 
    		}
    		}else{ ?>
    		<tr>
    		<td><p>No topics to list</p></td>
    		</tr>
    		<? } ?>
          </table>
        <!-- InstanceEndEditable --></td>
      </tr>
      <tr>
        <td colspan="2" class="copyright">Copyright&copy;2006</td>
      </tr>
    </table>
    </body>
    <!-- InstanceEnd --></html>
    ryanreese.net/articles/blog/

    Notice no errors (I manually inserted one)
    http://ryanreese.net/articles/blog/comments.php?aid=0

    No errors and you see the thing

    http://ryanreese.net/articles/blog/comments.php?aid=4

    Error...How do I get jjust a freaking simple comments script (I'll use a different script). I'm currently using the php blog script from devshed. I'm so confused I just want a simple comment system for my articles...I had this working previously
    Twitter-@Ryan_Reese09
    http://www.ryanreese.us -Always looking for web design/development work

  2. #2
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    You'd be better off just writing one from scratch to be honest. Pre-written scripts are going to be a waste of your time.

    Do you know where to start?
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  3. #3
    billycundiff{float:left;} silver trophybronze trophy RyanReese's Avatar
    Join Date
    Oct 2008
    Location
    Whiteford, Maryland, United States
    Posts
    13,564
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    No idea...I am so bad at PHP I would consider hiring someone.
    Twitter-@Ryan_Reese09
    http://www.ryanreese.us -Always looking for web design/development work

  4. #4
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    In that case, have you considered something like wordpress for your blog? It comes loaded with comments etc, and has a massive user-base (meaning resources (templates, plugins) galore).

    Off Topic:


    No idea...I am so bad at PHP
    Maybe a change of sig is required?
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  5. #5
    billycundiff{float:left;} silver trophybronze trophy RyanReese's Avatar
    Join Date
    Oct 2008
    Location
    Whiteford, Maryland, United States
    Posts
    13,564
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    Let me reiterate . It's my worst language. I could essentially make one...but honestly I'm just looking for a free one. Hmm...if you could give me the sql code I'll do it (sql is my worst actually, or JS. Rudy will argue JS, Raffles JS).

    Me love you long time if you do this arkinstall.
    Twitter-@Ryan_Reese09
    http://www.ryanreese.us -Always looking for web design/development work

  6. #6
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I won't do it for you

    Either come up with something yourself, or use a popular application such as Wordpress.

    Personally I wouldn't use that in my own site, but that's because I'd be willing/able to write it myself - for those who aren't (able or willing to learn), use something that has a large user-base.
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  7. #7
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,788
    Mentioned
    151 Post(s)
    Tagged
    3 Thread(s)
    works for me.....
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  8. #8
    billycundiff{float:left;} silver trophybronze trophy RyanReese's Avatar
    Join Date
    Oct 2008
    Location
    Whiteford, Maryland, United States
    Posts
    13,564
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    Spikez, what was the SQL you used-and it did not work for me. Did you check al the links?
    Twitter-@Ryan_Reese09
    http://www.ryanreese.us -Always looking for web design/development work

  9. #9
    billycundiff{float:left;} silver trophybronze trophy RyanReese's Avatar
    Join Date
    Oct 2008
    Location
    Whiteford, Maryland, United States
    Posts
    13,564
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    All I want is users to be able to share their thoughts....(I don't see why you are not getting an error, nor me...I was getting one eralier though)
    Twitter-@Ryan_Reese09
    http://www.ryanreese.us -Always looking for web design/development work

  10. #10
    billycundiff{float:left;} silver trophybronze trophy RyanReese's Avatar
    Join Date
    Oct 2008
    Location
    Whiteford, Maryland, United States
    Posts
    13,564
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    Any place to help get me started?
    Twitter-@Ryan_Reese09
    http://www.ryanreese.us -Always looking for web design/development work

  11. #11
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,788
    Mentioned
    151 Post(s)
    Tagged
    3 Thread(s)
    OK maybe I am missing something here but you haven't actually said what the problem is...
    Are you getting error messages? should there be something on the page that isnt? The insert works on my 'spikey test' insert and is displayed without error.....
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  12. #12
    billycundiff{float:left;} silver trophybronze trophy RyanReese's Avatar
    Join Date
    Oct 2008
    Location
    Whiteford, Maryland, United States
    Posts
    13,564
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    I'm..just looking for a simple script that allows users to comment on my site. (scrap the code)
    Twitter-@Ryan_Reese09
    http://www.ryanreese.us -Always looking for web design/development work


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •