Jump to content

Adamb10

Members
  • Posts

    19
  • Joined

  • Last visited

    Never

About Adamb10

  • Birthday 12/27/1988

Contact Methods

  • AIM
    segsp
  • MSN
    adamb106@msn.com
  • Website URL
    http://adamb10.com

Profile Information

  • Gender
    Not Telling
  • Location
    Milwaukee, Wisconsin

Adamb10's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Well my old way involved using the fields to store the data and stuff never involving with columns and rows.  Thats what I'm trying to fix and develop a new way.
  2. I made a powerful guestbook script months ago.  It was my most advanced script since it had advanced features but it lacked efficentcy.  In order to fix that I tried recoding the query backend which thus forced a complete DB redesign.  If I have a table called "settings" which would store items such as feature enabling/disabling, the title, and other various options what fields would I create?  I get Fields, rows and columns mixed up alot.  :( Thanx
  3. haha oops sorry. Wasnt thinking, was watching the baseball game. Heres the code... [code] <? // START MEMORY BUFFER ob_start(); //index.php //Start the session session_start(); //Load required files require('sources/functions.php'); //COUNTER STSRT $c_ip = $HTTP_COOKIE_VARS["user_ip"]; $counter_file = "sources/counter.txt"; $counter_file_line = file ($counter_file); if(!$c_ip) { setcookie("user_ip", $REMOTE_ADDR, time()+360000);  $counter_file_line[0]++; $cf = fopen ($counter_file, "w+");fputs($cf, "$counter_file_line[0]"); fclose($cf); } elseif($c_ip != $REMOTE_ADDR){ $counter_file_line[0]++; $cf = fopen ($counter_file, "w+"); fputs($cf, "$counter_file_line[0]"); fclose($cf); } //END COUNTER //Essential Functions db_connect(); //Prepare for Query in 5..4..3..2..1 function query($query){     $sql = "$query";     $result = mysql_query($sql);     return mysql_fetch_array ($result); } // Figure out the limit for the query based // on the current page number. $from = ($page * $max_results); //QUERY START $row = query("SELECT * FROM settings"); //settings query $row1 = query("SELECT * FROM colors"); //colors query $max_results = $row['maxshow']; $q1 = 'SELECT * FROM Bans'; //ban query       $r1 = mysql_query($q1) or die(mysql_error()); if($row['postorder'] == "descend") { //Comment Query 1   $q = 'SELECT * FROM comments ORDER BY Date DESC LIMIT '.$from.', '.$max_results.'';        $r = mysql_query($q) or die(mysql_error());      } else{ if($row['postorder'] == "ascend"){ //Comment Query 2 $q = 'SELECT * FROM comments ORDER BY Date ASC LIMIT '.$from.', '.$max_results.'';        $r = mysql_query($q) or die(mysql_error());     } } $hf = query("SELECT * FROM hf"); //HF Query if (!$hf) {    die('Invalid query: ' . mysql_error());    } //QUERY END //CSS BEGIN echo ' <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd"> <head> <title>'.$row['title'].'</title>     <meta http-equiv="Content-Type" content="text/html; charset=utf-8">     <style type="text/css"> <!-- a:link {     color: #'.$row1['link'].';     text-decoration: none; } a:visited {     color: #'.$row1['visitedlink'].';     text-decoration: none; } a:active {     color: #'.$row1['activelink'].';     text-decoration: none; } a:hover {     color: #'.$row1['hoverlink'].';     text-decoration: none;     } body {     background-color: #'.$row1['bodybg'].';     font-family: '.$row1['fontfamily'].';     font-size: '.$row1['fontsize'].';     color: #'.$row1['font'].';     margin:0px;     '; if ($row1['bodybgimage'] != "") { echo 'background-image: url('.$row1['bodybgimage'].');'; } echo '     } .titlebg {     background-color: #'.$row1['titlebg'].';     font-family: '.$row1['titlefontfamily'].';     font-size: '.$row1['titlefontsize'].';     color: #'.$row1['titlefont'].'; ';     if ($row1['tilebgimage'] == "") {     echo '     background-image: url('.$row1['titlebgimage'].');'; }         echo '         } .windowbg {     background-color: #'.$row1['windowbg'].';     font-family: '.$row1['windowfontfamily'].';     font-size: '.$row1['windowfontsize'].';     color: #'.$row1['windowfont'].';';     if ($row1['windowbgimage'] != "") {     echo 'background-image: url('.$row1['windowbgimage'].');';     }     echo '     } .windowbg2 {     background-color: #'.$row1['window2bg'].';     font-family: '.$row1['window2fontfamily'].';     font-size: '.$row1['window2fontsize'].';     color: #'.$row1['window2font'].';';     if($row1['window2bgimage'] != "") {     echo 'background-image: url('.$row1['window2bgimage'].');';     }        echo '      } .border {     background-color: #'.$row1['border'].';     } td {     font-size: 11px;     } input,textarea {     font-family: '.$row1['fontfamily'].';     font-size: 11px;     } select {     font-family: '.$row1['fontfamily'].';     font-size: 11px;     }     --!>     </style>     <title>'.$row1['title'].'</title> </head> <body>'; //CSS END if($_GET['action'] == "") { getUserIp(); } //echo out the Guestbook Header guestbook_header(); echo '<br><br><br>'; require('sources/actions.php'); //Check if this really is index.php. if($_GET['action'] == "") { echo '<br>'.$hf['header'].''; if($row['posting'] == "enabled") { if($row['kwikpost'] == "yes"){ if($row['kwikpostlocation'] == "top"){ kwikpost(); } }} } //PAGINATON STARTS HERE if(!isset($_GET['page'])){     $page = 0; } else {     $page = $_GET['page']; } echo '<br><br> <table style="width: 55%;" class="border" border="0" cellpadding="4" cellspacing="1" align="center">'; //COMMENT SYSTEM BEGIN if($_GET['action'] == ""){ $total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM comments"),0); // Figure out the total number of pages. Always round up using ceil() $total_pages = ceil($total_results / $max_results); echo '<center>Select a Page: '; // Build Page Number Hyperlinks if($page > 0){     $prev = ($page - 1);     echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$prev\"><<Previous</a> "; } for($i = 0; $i <= $total_pages; $i++){     if(($page) == $i){         echo "$i ";         } else {             echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a> ";     } } // Build Next Link if($page < $total_pages){     $next = ($page + 1);     echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$next\">Next>></a>"; } { while($row = mysql_fetch_array($r)){ ///END PAGINATION, PROCEED TO NORMAL CODE echo "</center>"; $date = explode("|", $row['date']);             $name = $row['name'];             $comment = $row['comment'];             $email = $row['email'];             $website = $row['website'];             $hideemail = $row['hideemail']; if(!isset($cmd)){ echo ' <tr class="windowbg2">           <td style="width: 27%;">'; //HI, WHATS YOUR NAME?            echo           "$name          <br>";          if($hideemail != "o") {          echo "          <a href=\"mailto: $email\">              [email]</a>";                       }             if($website != "") {             echo "<a href=\"$website\">[website]</a>";             }             echo '                    </td>         <td>';        //DATE SYSTEM        $d = $row['date'];                 $month = date("M");                 $day = date("d");                 $year = date("Y"); //MORE DATESYSTEN echo 'Posted on '; if($date['0']==$month && $date['1']==$day && $date['3']==$year){                         echo '<b>Today</b>';                 } elseif($date['0']==$month && $date['1']==$day-1 && $date['3']==$year){                         echo '<b>Yesterday</b>';                 } else {                         echo '<b>'.$date['0'].' '.$date['1'].''.$date['2'].', '.$date['3'].'</b>';                 }                 echo ' at <b>'.$date['4'].'</b>';         } echo   "<br><br>        $comment            </td>     </tr>";    } echo ' <table> <br>'; //KWIK POST $row = query("SELECT * FROM settings"); if($row['posting'] == "enabled") { if($row['kwikpost'] == "yes"){ if($row['kwikpostlocation'] == "bottom"){ kwikpost(); }}} echo ' '.$hf['footer'].'';         }} //COMMENT SYSTEM END copyright(); // FLUSH MEMORY BUFFER (CLEANER THEN LEAVING IT OUT) ob_flush(); ?> [/code]
  4. I added a feature that allows the user to set the # of comments per page the software will show. It appears that that featured broke pagination though. Specifically...this line.. [code] $max_results = $row['maxshow']; [/code] Originally $max_results was hardcoded to = 3 but now that its set to whatever is in the DB, not working anymore.
  5. [!--quoteo(post=387703:date=Jun 25 2006, 02:25 AM:name=shortj75)--][div class=\'quotetop\']QUOTE(shortj75 @ Jun 25 2006, 02:25 AM) [snapback]387703[/snapback][/div][div class=\'quotemain\'][!--quotec--] try changing this [code] if($row['postorder'] == "descend") { //Comment Query 1   $q = 'SELECT * FROM comments ORDER BY Date DESC';        $r = mysql_query($q) or die(mysql_error());        } elseif($row['postorder'] == "ascend"){ //Comment Query 2       $q = 'SELECT * FROM comments ORDER BY Date ASC';        $r = mysql_query($q) or die(mysql_error());     } [/code] to this [code] if($row['postorder'] == "descend") { //Comment Query 1   $q = 'SELECT * FROM comments ORDER BY Date DESC';        $r = mysql_query($q) or die(mysql_error());        } else{ if($row['postorder'] == "ascend"){ //Comment Query 2       $q = 'SELECT * FROM comments ORDER BY Date ASC';        $r = mysql_query($q) or die(mysql_error());     } }[/code] you forgot to put { after else and with that you would need to add } at the end try that and see if it helps [/quote] Doesnt help at all I dont think. Please note that I have this code in several files too... [code] $q1 = 'SELECT * FROM Bans'; //ban query       $r1 = mysql_query($q1) or die(mysql_error()); if($_GET['action'] == "login") { $ip1 = $_SERVER['REMOTE_ADDR']; //grab the users ip address while($row = mysql_fetch_array($r1)){ $ip = $row['ip']; $reason = $row['reason']; if($ip==$ip1){ error('You ('.$ip.') have been baned from this guestbook for '.$reason.''); } } if($ip != $ip1) { [/code]
  6. This is hard to explain but here it goes... I implented a ban system in my guestbook software, ban by ip. However I have a problem with it. When Im not banned I cant access the admin center and add new post page which I should be able to. All I get is a blank page. When I am baned though it works, I get an error message saying im baned and the reason. Heres the code of index.php. [code] <? //index.php //Start the session session_start(); //Load required files require('sources/functions.php'); //Counters are cool, I think we need one... $c_ip = $HTTP_COOKIE_VARS["user_ip"]; $counter_file = "sources/counter.txt"; $counter_file_line = file($counter_file); if(!$c_ip) { setcookie("user_ip", $REMOTE_ADDR, time()+360000);  $counter_file_line[0]++; $cf = fopen ($counter_file, "w+"); fputs($cf, "$counter_file_line[0]"); fclose($cf); } elseif($c_ip != $REMOTE_ADDR){ $counter_file_line[0]++; $cf = fopen ($counter_file, "w+"); fputs($cf, "$counter_file_line[0]");   fclose($cf); } //Essential Functions db_connect(); //Prepare for Query in 5..4..3..2..1 function query($query){      $sql = "$query";      $result = mysql_query($sql);      return mysql_fetch_array ($result); } //Query time! $row = query("SELECT * FROM settings"); //settings query $row1 = query("SELECT * FROM colors"); //colors query $q1 = 'SELECT * FROM Bans'; //ban query        $r1 = mysql_query($q1) or die(mysql_error()); if($row['postorder'] == "descend") { //Comment Query 1   $q = 'SELECT * FROM comments ORDER BY Date DESC';        $r = mysql_query($q) or die(mysql_error());        } elseif($row['postorder'] == "ascend"){ //Comment Query 2       $q = 'SELECT * FROM comments ORDER BY Date ASC';        $r = mysql_query($q) or die(mysql_error());     } $hf = query("SELECT * FROM hf"); //HF Query if (!$hf) {     die('Invalid query: ' . mysql_error());     } //Lets output the html echo ' <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd"> <head> <title>'.$row['title'].'</title>      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">      <style type="text/css"> <!-- a:link {      color: #'.$row1['link'].';      text-decoration: none; } a:visited {      color: #'.$row1['visitedlink'].';      text-decoration: none; } a:active {      color: #'.$row1['activelink'].';      text-decoration: none; } a:hover {      color: #'.$row1['hoverlink'].';      text-decoration: none;      } body {      background-color: #'.$row1['bodybg'].';      font-family: '.$row1['fontfamily'].';      font-size: '.$row1['fontsize'].';      color: #'.$row1['font'].';      margin:0px;      '; if ($row1['bodybgimage'] != "") { echo 'background-image: url('.$row1['bodybgimage'].');'; } echo '      } .titlebg {      background-color: #'.$row1['titlebg'].';      font-family: '.$row1['titlefontfamily'].';      font-size: '.$row1['titlefontsize'].';      color: #'.$row1['titlefont'].'; ';      if ($row1['tilebgimage'] == "") {      echo '      background-image: url('.$row1['titlebgimage'].');'; }          echo '          } .windowbg {      background-color: #'.$row1['windowbg'].';      font-family: '.$row1['windowfontfamily'].';      font-size: '.$row1['windowfontsize'].';      color: #'.$row1['windowfont'].';';      if ($row1['windowbgimage'] != "") {      echo 'background-image: url('.$row1['windowbgimage'].');';      }      echo '      } .windowbg2 {      background-color: #'.$row1['window2bg'].';      font-family: '.$row1['window2fontfamily'].';      font-size: '.$row1['window2fontsize'].';      color: #'.$row1['window2font'].';';      if($row1['window2bgimage'] != "") {      echo 'background-image: url('.$row1['window2bgimage'].');';      }         echo '       } .border {      background-color: #'.$row1['border'].';      } td {      font-size: 11px;      } input,textarea {      font-family: '.$row1['fontfamily'].';      font-size: 11px;      } select {      font-family: '.$row1['fontfamily'].';      font-size: 11px;      }      --!>      </style>      <title>'.$row1['title'].'</title> </head> <body>'; //Ban System if($_GET['action'] == "") { $ip1 = $_SERVER['REMOTE_ADDR']; //grab the users ip address while($row = mysql_fetch_array($r1)){ $ip = $row['ip'];   $reason = $row['reason']; if($ip==$ip1){ error('You ('.$ip.') have been baned from this guestbook for '.$reason.''); } } } if($ip != $ip1) { //echo out the Guestbook Header guestbook_header(); echo '<br><br><br>'; require('sources/actions.php'); //Check if this really is index.php. if($_GET['action'] == "") { echo '<br>'.$hf['header'].''; if($row['posting'] == "enabled") { if($row['kwikpost'] == "yes"){ if($row['kwikpostlocation'] == "top"){ kwikpost(); } }} } echo '<br><br> <table style="width: 55%;" class="border" border="0" cellpadding="4" cellspacing="1" align="center">'; //Prepare the comment system... if($_GET['action'] == "") {   while($row = mysql_fetch_array($r)){   $date = explode("|", $row['date']);              $name = $row['name'];              $comment = $row['comment'];              $email = $row['email'];              $website = $row['website']; if(!isset($cmd)){ echo '   <tr class="windowbg2">            <td style="width: 27%;">';            //Hi, whats your name?             echo            "$name           <br><a href=\"mailto: $email\">               [email]</a>";                                      if($website != "") {              echo "<a href=\"$website\">[website]</a>";              }              echo '                       </td>          <td>';          //Date System         $d = $row['date'];          $month = date("M");          $day = date("d");          $year = date("Y"); //Was the comment posted yesterday or today? echo 'Posted on '; if($date['0']==$month && $date['1']==$day && $date['3']==$year){              echo '<b>Today</b>';          } elseif($date['0']==$month && $date['1']==$day-1 && $date['3']==$year){              echo '<b>Yesterday</b>';          } else {              echo '<b>'.$date['0'].' '.$date['1'].''.$date['2'].', '.$date['3'].'</b>';          }          echo ' at <b>'.$date['4'].'</b>';      } echo   "<br><br>          $comment             </td>      </tr>";     } echo ' <table> <br>'; //Kwik Post time! $row = query("SELECT * FROM settings"); if($row['posting'] == "enabled") { if($row['kwikpost'] == "yes"){ if($row['kwikpostlocation'] == "bottom"){ kwikpost(); }}} echo ' '.$hf['footer'].'';      } copyright();          } ?> [/code] Thanks!!
  7. Now, I cant get the code that actually edit's the DB to work. Ah well, Im sure I can tackle it on my own. :)
  8. Yep that was it, I moved the textboxes to a new file and now it works. Thanks!!
  9. hmmm... I see. I should probobly close that if statement earlier then?
  10. ummm..I posted the code on the last page, but heres more of it. [code] if(!isset($cmd)) { $result = mysql_query("select * from comments order by id"); while($r=mysql_fetch_array($result))    {    $name=$r["name"]; //take out the title       $id=$r["id"]; //Take out the id    $date=$r["date"]; // Take out the Date    echo "        <tr>         <td class='windowbg2'>$id</td>         <td class='windowbg2'>$name</td>         <td class='windowbg'><a href='?action=comments&cmd=edit&id=$id'>Edit</a></td>         <td class='windowbg'><a href='?action=comments&cmd=delete&id=$id'>Delete</a></td>     </tr>          </center>";     if($_GET["cmd"]=="edit" || $_POST["cmd"]=="edit") {    if (!isset($_POST["submit"]))    {       $id = $_GET["id"];       $sql = "SELECT * FROM comments WHERE id=$id";       $result = mysql_query($sql);               $myrow = mysql_fetch_array($result); //PHP, we need you to cool down so get a drink and relax.   ?>       <form action='?action=editing' method='post'>       <input type=hidden name='id' value="<? echo $myrow["id"] ?>">       <table width='100%' cellspacing='0' cellpadding='0' border='0'>                 <td class='titlebg' colspan='2'><b>Edit Comment</b></td>         </tr><tr>                     <td class='windowbg2' width='30%'><b>Name:</b><br>             <font class='subtext'>The name the person used to tell who they are.</font></td>             <td class='windowbg'><input type='text' name='title' size='40' value="<? echo $myrow["name"] ?>"></td>         </tr><tr>             <td class='windowbg2' width='30%'><b>Email:</b><br>             <font class='subtext'>The email the person used to be contacted.</font></td>             <td class='windowbg'><input type='text' name='name' size='40' value="<? echo $myrow["email"] ?>"></td>         </tr><tr>         <td class='windowbg2' width='30%'><b>Website:</b><br>             <font class='subtext'>The website the person entered in.  This field is optional</font></td>             <td class='windowbg'><input type='text' name='name' size='40' value="<? echo $myrow["website"] ?>"></td>         </tr><tr>         <td class='windowbg2' width='30%'><b>Comment:</b><br>             <font class='subtext'>The comment the user entered in.</font></td>             <td class='windowbg'><textarea name='comment' cols='38' rows='5'><? echo $myrow["comment"] ?></textarea></td>              <input type='hidden' name='cmd' value='edit'>              </tr>         <tr>             <td class='titlebg' colspan='2' align='right'><input type='submit' value='Edit Comment'> <input type='reset' value='Reset'></td></tr>             </form>             <?                      }                      }                      }                  }          [/code]
  11. [img src=\"http://www.adamb10.com/edit2.jpg\" border=\"0\" alt=\"IPB Image\" /] Theres the new screenshot, what it looks like after you hit edit.
  12. :p Right now I just wanna get a working script and then optimize/clean it up. P.S. Adding a & and removing the ? kinda works. I get the same page only without the posts.
  13. Second edit? Theres only 1 edit you click to get to the form. [img src=\"http://adamb10.com/edit.jpg\" border=\"0\" alt=\"IPB Image\" /] OR... [a href=\"http://adamb10.com/ub2/?action=login\" target=\"_blank\"]http://adamb10.com/ub2/?action=login[/a] adam/hakkar are the login details Click comments Click Edit for any of the comments
  14. Instead of creating a new topic... I got the code to run thanks to starting and stopping PHP like previously mentioned. Now I got another problem(not a parse error :)). The whole purpose of this file is to let the admin edit/delete comments. When the admin clicks edit to edit a topic, the url goes to ?action=comments?cmd=edit&id=15. Unfortuantely, when I do click edit, it goes to a blank page instead of a few text boxes. The code for this is right here... [code] if($_GET["cmd"]=="edit" || $_POST["cmd"]=="edit") {    if (!isset($_POST["submit"]))    { [/code] I use the action urls system where every action(like ?action=logout) is stored in actions.php. Heres a sampling from that file... [code] $action = $_GET['action']; if($action == "login"){     require('login.php'); } if($action =="admin"){     require('admin/admin.php'); } [/code] Any reason this wont work? Thanks!
  15. I did do that Caesar(just not in this file), but in this file nothing works.
×
×
  • 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.