usage
	index.php
	list.php
	sql
	OZZIE can u please help im getting error when trying to add poems  where did i make the falt in this code of urs did i miss anything out?
							
						
					Code:
	
	echo "<img src=\"images/new.gif\" alt=\"\"/><a href=\"lists.php?action=allpo&sid=$sid\">Members Poems!!</a><br/>";
Code:
	
	////////////////////////////////////////////////////////////////ADD POEMS ///////////////////////
else if($action=="addpoem")
{
addonline(getuid_sid($sid),"XHTML - Adding a Poem","");
 
    boxstart("Add A New Poem!");
	
    echo "<form action=\"index.php?action=addpoem2&sid=$sid\" method=\"post\">";
    echo "Title:<br/><input id=\"inputText\" name=\"btitle\" maxlength=\"255\"><br/>";
    echo "Text:<br/><textarea id=\"inputText\" name=\"msgtxt\" rows=\"8\"></textarea><br/>";
    echo "<input type=\"Submit\" id=\"inputText\" name=\"Add\" Value=\"Add\"></form>";
              
 
    
boxend();
getfooter($sid);
}
//////////////////////////////////////////////
else if($action=="viewpoem")
{
  $bid = $_GET["bid"];
  addonline(getuid_sid($sid),"XHTML - Viewing A Users Poem","");
    	    boxstart("View Poems!");
	  
  
  $pminfo = mysql_fetch_array(mysql_query("SELECT btext, bname, bgdate,bowner, id FROM ibwf_poems WHERE id='".$bid."'"));
    $bttl = htmlspecialchars($pminfo[1]);
    $btxt = parsemsg($pminfo[0], $sid);
	$btxt2=nl2br($btxt);
  $tmstamp = $pminfo[2];
  $tmdt = date("d/m/y @ h:i:s", $tmstamp);
    $bnick = getnick_uid($pminfo[3]);
  $vbbl = "<a href=\"index.php?action=viewuser&who=$pminfo[3]&sid=$sid\">$bnick</a><br/>Posted: $tmdt<br/>";
  echo "Poem ID: <b>$bid</b><br/>";
    echo "<b>$bttl</b> by: $vbbl<br/>";
  echo "$btxt2<br/><br/>";
  $vb = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_prate WHERE uid='".$uid."' AND blogid='".$bid."'"));
  if($vb[0]==0)
  {
  echo "<form action=\"genproc.php?action=ratep&bid=$pminfo[4]&sid=$sid\" method=\"post\">";
  echo "<select id=\"inputText\" name=\"brate\">";
  echo "<option id=\"inputText\" value=\"1\">1</option>";
  echo "<option id=\"inputText\" value=\"2\">2</option>";
  echo "<option id=\"inputText\" value=\"3\">3</option>";
  echo "<option id=\"inputText\" value=\"4\">4</option>";
  echo "<option id=\"inputText\" value=\"5\">5</option>";
  echo "</select><br/>";
  echo "<br/><input type=\"Submit\" id=\"inputText\" Name=\"Rate\" Value=\"Rate\"></form>";
  
  }else{
    $rinfo = mysql_fetch_array(mysql_query("SELECT COUNT(*) as nofr, SUM(brate) as nofp FROM ibwf_prate WHERE blogid='".$bid."'"));
    $ther = $rinfo[1]/$rinfo[0];
    echo "Rate: $ther - Points: $rinfo[1]";
  }
  
  echo "<a href=\"lists.php?action=allpo&sid=$sid\">Back to Poems</a><br/>";
  $bnick = getnick_uid($pminfo[3]);
  echo "<a href=\"index.php?action=poems&who=$pminfo[3]&sid=$sid\">Back to $bnick's Poems</a><br/>";
  
  
  
    boxend();
getfooter($sid);
}
//////////////////////////
else if($action=="addpoem2")
{
if(!getplusses(getuid_sid($sid))>50)
    {
      boxstart("Add Poem!");
	
            
      echo "You Can Only Create Poems If You Have 50+ Plusses<br/><br/>";
      
      boxend();
getfooter($sid);
      exit();
    }
  $msgtxt = $_POST["btitle"];
  $msgtxt = $_POST["msgtxt"];
  //$qut = $_POST["qut"];
  addonline(getuid_sid($sid),"XHTML - Adding a Poem","");
      boxstart("Add Poem!");
      $crdate = time();
      //$uid = getuid_sid($sid);
      $res = false;
      if((trim($msgtxt)!="")&&(trim($btitle)!=""))
      {
      $res = mysql_query("INSERT INTO ibwf_poems SET bowner='".$uid."', bname='".$btitle."', bgdate='".$crdate."', btext='".$msgtxt."'");
      }
      if($res)
      {
        echo "<img src=\"images/ok.gif\" alt=\"O\"/>Message Posted Successfully";
		
      }else{
        echo "<img src=\"images/notok.gif\" alt=\"X\"/>Error Posting Message";
      }
      echo "<br/><br/>";
      boxend();
getfooter($sid);
}
//////////////////////////////////////////////////////////////////////////////////////
else if($action=="poems")
{
    addonline(getuid_sid($sid),"XHTML - Viewing A Users Poem","");
              boxstart("Poems List!");
	
    $uid = getuid_sid($sid);
    $who = $_GET["who"];
    $tnick = getnick_uid($who);
    
    echo "<b>$tnick's Poems</b>";
    
    //////ALL LISTS SCRIPT <<
    if($page=="" || $page<=0)$page=1;
    $noi = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_poems WHERE bowner='".$who."'"));
    $num_items = $noi[0]; //changable
    $items_per_page= 10;
    $num_pages = ceil($num_items/$items_per_page);
    if(($page>$num_pages)&&$page!=1)$page= $num_pages;
    $limit_start = ($page-1)*$items_per_page;
        $sql = "SELECT id, bname FROM ibwf_poems WHERE bowner='".$who."' ORDER BY bgdate DESC LIMIT $limit_start, $items_per_page";
    echo "<p>";
    $items = mysql_query($sql);
    echo mysql_error();
    if(mysql_num_rows($items)>0)
    {
    while ($item = mysql_fetch_array($items))
    {
        $bname = htmlspecialchars($item[1]);
    if(candelbl($uid,$item[0]))
    {
      $dl = "<a href=\"genproc.php?action=delpo&bid=$item[0]&sid=$sid\">[X]</a>";
    }else{
      $dl = "";
    }
      $lnk = "<a href=\"index.php?action=viewpoem&bid=$item[0]&sid=$sid\">»$bname</a>";
      echo "$lnk $dl<br/>";
    }
    }
    echo "</p>";
    echo "<p>";
    if($page>1)
    {
      $ppage = $page-1;
      echo "<a href=\"lists.php?action=$action&page=$ppage&who=$who&sid=$sid\">«PREV</a> ";
    }
    if($page<$num_pages)
    {
      $npage = $page+1;
      echo "<a href=\"lists.php?action=$action&page=$npage&who=$who&sid=$sid\">Next»</a>";
    }
    echo "<br/>$page/$num_pages<br/>";
    echo "</p>";
  ////// UNTILL HERE >>
    echo "<p>";
    if($who==$uid)
    {
        echo "<a href=\"index.php?action=addpoem&sid=$sid\">";
echo "Add a Poem</a><br/>";
echo "<a href=\"index.php?action=cpanel&sid=$sid\">";
echo "User Settings</a><br/>";
    }
    echo "<a href=\"lists.php?action=allpo&sid=$sid\">";
echo "All Poems</a><br/>";
    boxend();
getfooter($sid);
}
Code:
	
	/////////////////////////////////////////////////////////// All Poems
else if($action=="allpo")
{
    addonline(getuid_sid($sid),"XHTML - Viewqing Poems list","");
              boxstart("All Poems!");
	
    $uid = getuid_sid($sid);
    $view = $_GET["view"];
    if($view =="")$view="time";
    echo "<small>";
    
    echo "</small></p>";
    //////ALL LISTS SCRIPT <<
    
    if($page=="" || $page<=0)$page=1;
    $noi = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_poems"));
    $num_items = $noi[0]; //changable
    $items_per_page= 7;
    $num_pages = ceil($num_items/$items_per_page);
    if(($page>$num_pages)&&$page!=1)$page= $num_pages;
    $limit_start = ($page-1)*$items_per_page;
if($view=="time")
{
  $ord = "a.bgdate";
}else if($view=="votes")
{
  $ord = "nofv";
}else if($view=="rate")
{
  $ord = "avv";
}else if($view=="points")
{
  $ord = "nofp";
}
if ($view=="time"){
  $sql = "SELECT id, bname, bowner FROM ibwf_poems ORDER by bgdate DESC LIMIT $limit_start, $items_per_page";
}else{
        $sql = "SELECT a.id, a.bname, a.bowner, COUNT(b.id) as nofv, SUM(b.brate) as nofp, AVG(b.brate) as avv FROM ibwf_poems a INNER JOIN ibwf_prate b ON a.id = b.blogid GROUP BY a.id ORDER BY $ord DESC LIMIT $limit_start, $items_per_page";
}
    echo "<small>";
    $items = mysql_query($sql);
    echo mysql_error();
    if(mysql_num_rows($items)>0)
    {
    while ($item = mysql_fetch_array($items))
    {
      $bname = htmlspecialchars($item[1]);
      if($view=="time")
      {
      $bonick = getnick_uid($item[2]);
        
        $byview = "by <a href=\"index.php?action=viewuser&who=$item[2]&sid=$sid\">$bonick</a>";
        }else if($view=="votes")
        {
          $byview = "Votes: $item[3]";
        }else if($view=="rate")
        {
          $byview = "Rate: $item[5]";
        }else if($view=="points")
        {
          $byview = "Points: $item[4]";
        }
      $lnk = "<a href=\"index.php?action=viewpoem&bid=$item[0]&sid=$sid\">»$bname</a> $byview";
      echo "$lnk<br/>";
    }
    }
    echo "</small>";
    
    if($page>1)
    {
      $ppage = $page-1;
      echo "<a href=\"lists.php?action=$action&page=$ppage&view=$view&sid=$sid\">«PREV</a> ";
    }
    if($page<$num_pages)
    {
      $npage = $page+1;
      echo "<a href=\"lists.php?action=$action&page=$npage&view=$view&sid=$sid\">Next»</a>";
    }
    echo "<br/>$page/$num_pages<br/>";
        if($view!="time")
    {
      echo "<a href=\"lists.php?action=allpo&view=time&sid=$sid\">View Newest</a><br/>";
    }
    if($view!="points")
    {
      echo "<a href=\"lists.php?action=allpo&view=points&sid=$sid\">View by points</a><br/>";
    }
    if($view!="rate")
    {
      echo "<a href=\"lists.php?action=allpo&view=rate&sid=$sid\">View most rated</a><br/>";
    }
    if($view!="votes")
    {
      echo "<a href=\"lists.php?action=allpo&view=votes&sid=$sid\">View most voted</a>";
    }
  ////// UNTILL HERE >>
    echo "<p>";
echo "<a href=\"index.php?action=addpoem&sid=$sid\">";
echo "Add a Poem</a><br/>";
      
    boxend();
getfooter($sid);
}
Code:
	
	-- -- Table structure for table `ibwf_poems` -- DROP TABLE IF EXISTS `ibwf_poems`; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; CREATE TABLE `ibwf_poems` ( `id` int(100) NOT NULL auto_increment, `bowner` int(100) NOT NULL default '0', `bname` varchar(255) NOT NULL default '', `btext` blob NOT NULL, `bgdate` int(100) NOT NULL default '0', PRIMARY KEY (`id`), UNIQUE KEY `bname` (`bname`) ) ENGINE=MyISAM AUTO_INCREMENT=7 DEFAULT CHARSET=latin1; SET character_set_client = @saved_cs_client; -- -- Dumping data for table `ibwf_poems` -- LOCK TABLES `ibwf_poems` WRITE; /*!40000 ALTER TABLE `ibwf_poems` DISABLE KEYS */; INSERT INTO `ibwf_poems` (`id`, `bowner`, `bname`, `btext`, `bgdate`) VALUES (1,1,'dog','there once was a dog named bill',1237115639),(2,527,'cooolllllll','k\r\ne\r\na\r\nn\r\n\r\ni\r\nv\r\na\r\nn',1237118500),(3,565,'Jack n Jill','Jack and Jill went up the hill,to have a little fun,poor Jill forgot her pill,and now they have a son.',1237128126),(4,865,'Miiiiss You','I hide my tears when I say your name, but the pain in my heart is still the same, Although I Smile & Seem Carefree, There is no one Who misses you more than Me Mmmwah',1240168429),(5,671,'Read and Rate...','The chains have been unlocked.It fell with a melancholic thud on the floor.Inch by inch you\'re moving away.Never looking back as I\'m begging you to stay.But from far away I can see.The paradise is waiting,you need to be free.',1240194580),(6,865,'Miine Msg 4u','If U delete this message thats bcoz u love me. .. If u save it thats bcoz u desire me .. & if u ignore it thats bcoz u miss me. So what u gonna do with It?',1240240518); /*!40000 ALTER TABLE `ibwf_poems` ENABLE KEYS */; UNLOCK TABLES; -- Table structure for table `ibwf_prate` -- DROP TABLE IF EXISTS `ibwf_prate`; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; CREATE TABLE `ibwf_prate` ( `id` int(100) NOT NULL auto_increment, `blogid` int(100) NOT NULL default '0', `uid` int(100) NOT NULL default '0', `brate` char(1) NOT NULL default '', PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; SET character_set_client = @saved_cs_client; -- -- Dumping data for table `ibwf_prate` -- LOCK TABLES `ibwf_prate` WRITE; /*!40000 ALTER TABLE `ibwf_prate` DISABLE KEYS */; /*!40000 ALTER TABLE `ibwf_prate` ENABLE KEYS */; UNLOCK TABLES;


Comment