Jump to content

Johns3n

Members
  • Posts

    72
  • Joined

  • Last visited

Everything posted by Johns3n

  1. Sorry I am abit of a noobie at PHP So you mean my code should look a little like this? $related_data = mysql_query("SELECT title, id FROM " .$db_prefix. "updates WHERE NOT " .$db_prefix. "updates.id = ".$self." AND (" .$db_prefix. "updates.tags LIKE '%".$tags_explode[0]."%' OR " .$db_prefix. "updates.tags LIKE '%".$tags_explode[1]."%' OR " .$db_prefix. "updates.tags LIKE '%".$tags_explode[2]."%' OR " .$db_prefix. "updates.tags LIKE '%".$tags_explode[3]."%' OR " .$db_prefix. "updates.tags LIKE '%".$tags_explode[4]."%') ORDER BY id ASC LIMIT 5" );
  2. Hi PHPFreaks.com I'm currently having some trouble with a mySQL sentence, where i am trying to select other updates (posts in the database) based on the id that is not equal to the post that the user is viewing right now. It's basically a related updates system, so I don't wan't the update that you viewing right now to be displayed. Here is the SQL query that i wrote, which unfortunaly still also selects the post that the user is viewing. $related_data = mysql_query("SELECT title, id FROM " .$db_prefix. "updates WHERE NOT " .$db_prefix. "updates.id = ".$self." AND " .$db_prefix. "updates.tags LIKE '%".$tags_explode[0]."%' OR " .$db_prefix. "updates.tags LIKE '%".$tags_explode[1]."%' OR " .$db_prefix. "updates.tags LIKE '%".$tags_explode[2]."%' OR " .$db_prefix. "updates.tags LIKE '%".$tags_explode[3]."%' OR " .$db_prefix. "updates.tags LIKE '%".$tags_explode[4]."%' ORDER BY id ASC LIMIT 5" ); The $self variable is equal to the id of the post the user is viewing. Thanks in advance
  3. Thank you so much! I feel soo dumb for forgetting that.. hehe this is solved now.. thanks again mate
  4. Hi again folks at PHPfreaks! First off thanks for all the speedy answers i've gotten in the past when I had problems with either PHP and/or MySQL, I really appreciate you taking your time to help out us less-so-good-at-php designers out there With that said, I have some problems with a file upload script that I wrote, please bear in mind that the script is copied from another file of mine where it actually works, so I am abit staggered to see it isn't working now I made sure the folder where it tries put file is CHMOD'ed to "777" for full write access. So I am hoping that you maybe able to spot the error! Please notice that I run most of my scripts from the same file using _GET urls to determine what scripts run when and where.. like so: "upload.php?action=upload" <- Shows the Form where to upload the file "upload.php?action=insert" <- Runs the script to actually upload the file from the form But the above should be evident in the script below So hope that you maybe can see where I am wrong? elseif($action == "upload") { echo "<?xml version='1.0' encoding='utf-8'?> <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.1//EN' 'http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd'> <html xmlns='http://www.w3.org/1999/xhtml'> <head> <meta http-equiv='content-type' content='text/html; charset=utf-8' /> <meta name='robots' content='noindex,nofollow' /> <link href='css/admin.css' rel='stylesheet' type='text/css' media='all' /> <title>LÖRK(SOURCE) » Administrations Værktøj</title> <script type='text/javascript' src='js/javascript.js'></script> <body> <div id='loading' style=\"display: none;\"> <div id='overlay'></div> <div id='loading_progress'> <h2>Vent venligst</h2> <h3>Uploader...</h3> <img src='gfx/progress.gif' alt='Henter' /> <p>Dit indhold indsættes nu i databasen.</p> <p>Dette kan tage nogle minutter alt efter din internets forbindelse.</p> </div> </div> <div id='workarea'> <div id='form'> <form action='upload.php?action=insert' method='POST'> <input type='text' name='fakeupload' class='fake' /> <input type='file' name='uploadedfile' class='real' onchange='this.form.fakeupload.value = this.value;' /> <input type='submit' onclick=\"showStuff('loading');\" value='UPLOAD' class='upload_btn' /> <p>Klik på det hvide tekst felt for at vælge et billed til upload</p> </form> <a href='' </div> </body> </html>"; } elseif($action == "insert") { $file=$_FILES['uploadedfile']['name']; // Angiv fil sti og fil navn hvor plakaten skal gemmes $target_path = "../uploads/images/"; $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); // Hvis filen flyttes med succes vis meddelse if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { // Create SQL query to insert blog post into posts table $insert_file="INSERT INTO ". $db_prefix ."uploads (filename) VALUES ('$file')"; // Execute query to create blog post in posts table mysql_query($insert_file,$con); // Definere sti og fil navn på plakat der skal resizes $file_path="../uploads/images/$file"; // Definere sti og fil navn på plakat der skal resizes til infoskærms brug $thumb_path="../uploads/images/thumb_$file"; // Resize plakaten med simpleimage include('js/simpleimage.php'); $image = new SimpleImage(); // Resize Plakaten til infoskærm $image->load($file_path); $image->resize(145,160); $image->save($thumb_path); echo "<?xml version='1.0' encoding='utf-8'?> <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.1//EN' 'http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd'> <html xmlns='http://www.w3.org/1999/xhtml'> <head> <meta http-equiv='content-type' content='text/html; charset=utf-8' /> <meta name='robots' content='noindex,nofollow' /> <link href='css/admin.css' rel='stylesheet' type='text/css' media='all' /> <title>LÖRK(SOURCE) » Administrations Værktøj</title> <script type='text/javascript' src='js/javascript.js'></script> <body> <div id='workarea'> <p>WEEEE!</p> </div> </body> </html>"; } else { echo "AWWWW FUCK!!! DIDN'T WORK!!!"; } } If you have any questions regarding the code, please just post them Thanks in advance (yet again - Kenneth Johns3n
  5. Hi PHPFreaks.com I wrote in here a while ago about updating table rows by selecting rows which end dates is greater than the current day, much like a experation dates with blog posts in a CMS. I was told to make sure my datatype for the end dates in the database was the datetime format is YYYY-MM-DD HH:mm:SS now I have now changed that, but I am still have trouble creating a query that does exactly what I mentioned. mysql_query("UPDATE ". $db_prefix ."events WHERE end_time >= TIMESTAMP: Auto NOW() SET cat = 1" ); Now what I am trying to is that if the current time is greater than the end date I need the "cat" row changed to 1 So thanks in advance if you can help me guys
  6. I just realized i wrote the date format wrong It is "dd/mm/yyyy" But the overall problem still persists, so any help would still be appreciated
  7. First off! I am very sorry if I post this in the wrong forum, but I am having trouble with writing a SQL query in my PHP files, that I am doing for a project. I am writing a small CMS, and I need it to select all the events which's end date is less than or equal to the current server time. But using dates in PHP is really doing my head in, read alot of articles about the subject using Google but unfortunally they didn't help me as much as i had hoped Thats now why I turn to you folks at Phpfreaks.com Event table: ID - Title - Category - Event_date - End_date - End_time 1 Blah! Music 06/08/10 07/08/10 16:50:00 As you can see the end date is in the format "dd/mm/yy" and the end time is in "hh:mm:ss" So i am thinking that the SQL query must be something like (mind im a complete novice at PHP so this is just something that spawned top of my head!) $events_data = mysql_query("SELECT * FROM events WHERE End_date >= CURDATE(dd/mm/yy) AND End_time >= CURTIME(hh:mm:ss)" ); Unfortunally this doesn't work for me, so i hope you guys can help me in the right direction. btw I would be really sad if I would have to change the date format in Database because I already did a huge amount of code around that in this little CMS of mine. But looking forward to the help! and thanks in advance
  8. Tried what you said! And it's still not working! I'll post the changes I made: <form id='select_comments' name='select_comments' action='deletecomment.php?action=selected' method='post'> <input name='submit' type='button' value='Delete selected' onclick='javascript:confirmation_selected_comments()'/> <script type="text/javascript"> function confirmation_selected_comments() { var warning = confirm("Are you sure you want to delete selected entries?" + '\n' + '\n' + "This can NOT be undone!") if (warning) { document.select_comments.submit() } else { } } </script> Please note that I have placed the javascript outside the <form> tags but it should still work no? Also the stuff inside the <form> tags are posted within echo's that i close and open, close and open and close with the </form> but should still work regardless!
  9. Ahhh from what I read, it took the ID and not the name! But I tried switching it around so it looked like this: Form: <form id='select_comments' action='deletecomment.php?action=selected' method='post'> <input name='submit' type='button' value='Delete selected' onclick='javascript:confirmation_selected_comments()'/> Form submit script: <script type="text/javascript"> function confirmation_selected_comments() { var warning = confirm("Are you sure you want to delete selected entries?" + '\n' + '\n' + "This can NOT be undone!") if (warning) { document.getElementById('select_comments').submit(); } else { } } </script> Unfortunaly it's not working still
  10. Hello Folks! I was hoping that you could help me with a problem, regarding a form submission through JavaScript? The script it self does everything I want it to up to the part where it is suppose to submit the form. Here is the form with form id, form action and eveything needed to process a good form: <form name='select_comments' id='selected_comments' action='deletecomment.php?action=selected' method='post'> <input name='submit' type='button' value='Delete selected' onclick='javascript:confirmation_selected_comments()'/> Inside the form there are a few check boxes which I set up as being posted as a array of data, here is the code for the checkboxes: <input name='itemids[]' type='checkbox' value='" .$row['id']. "' /> If i remove all JavaScript and handle the form as a normal form would be handled, it processes all the data 100% correct, however I tried to implement a "confirmation box" that appears before you submit the form, just to verify if the user "really wan't to do this?" The script for the confirmation box I have written like this: <script type="text/javascript"> function confirmation_selected_comments() { var warning = confirm("Are you sure you want to delete selected entries?" + '\n' + '\n' + "This can NOT be undone!") if (warning) { document.selected_comments.submit(); } else { } } </script> Now the code used like this works up until it actually submits the form, it shows the confirmation box and askes, do you really want to do this? But when I click "ok" it does not submit the form to the action=' ' page, stated in the form. I did write the correct ID for the form in the document.submit string, but it's still not submitting the form, so I am hoping that you can maybe point in the right direction where I am going wrong? Thanks in Advance - Kenneth
  11. I told you i had looked myself blind on the problem thanks alot mate... thought i was past those dumb mistakes but obviously not
  12. Hi again, people at PHPfreaks.com I'm in abit of a kurfuffel with a page i wrote that is suppose to remind you of your user information, in case you forgot it.. but some strange reason it will not parse at all, and error reporting doesn't work either.. so im hoping that some of you maybe can see where i am wrong? as i am afraid i have stared myself blind looking for the error <?php ini_set('display_errors',1); error_reporting(E_ALL); include('../config.php'); // Check if the user already entered their email $mailed = mysql_real_escape_string($_GET['mailed']); // If the user already entered their email, begin processing it if ($mailed == "yes") { // Get email from form $email = mysql_real_escape_string($_POST['email']); // Define SQL query to see if the user exist sql = "SELECT * FROM ".$db_prefix."users WHERE email = '".$email."'"; // Execute SQL query $result = mysql_query($sql); // Mysql_num_row is counting the returned table rows $count = mysql_num_rows($result); // If 1 user is found create a email if($count >= 1) { // Create a mail containing the information while($row = mysql_fetch_assoc($result)) { $modtager = "" . $row['email'] . ""; $emne = "Username and Password reminder"; $besked = "You recently requested your username and/or password information for your user on the website: ".$site_url."\n \n \n Username: " . $row['username'] . "\n Password: " . $row['password'] . "\n \n \n After your first login, you should change your password again for security measures. It's not required, but strongly recommended. \n Best regards from:\n " .$site_url. " "; $header = "from:Lörk(source)"; } // Send the email with the username/password in it mail($modtager, $emne, $besked, $header); // Show a mail succesfully sent message echo "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.1//EN' 'http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd'> <html xmlns='http://www.w3.org/1999/xhtml'> <head> <title>Lörk(source) - Forgot your usename and/or password?</title> <meta name='Robots' content='NOINDEX' /> <meta http-equiv='Content-Type' content='text/html; charset=utf-8' /> <link href='admin/admin.css' rel='stylesheet' type='text/css' media='all' /> </head> <body> <div id='wrapper'> <div id='login_form'> <p>An email containing your user information have been sent to your e-mail</p> <form action='remind.php?mailed=yes' method='post'> <p>Please enter the your e-mail tied to your user:</p> <p><input name='email' type='text' class='email'/></p> <p><input name='submit' type='submit' value='Login' /></p> </form> </div> </div> </body> </html> "; } else { echo "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.1//EN' 'http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd'> <html xmlns='http://www.w3.org/1999/xhtml'> <head> <title>Lörk(source) - Forgot your usename and/or password?</title> <meta name='Robots' content='NOINDEX' /> <meta http-equiv='Content-Type' content='text/html; charset=utf-8' /> <link href='admin/admin.css' rel='stylesheet' type='text/css' media='all' /> </head> <body> <div id='wrapper'> <div id='login_form'> <p>No user with that email was found in the database, make sure you entered the correct e-mail</p> <form action='remind.php?mailed=yes' method='post'> <p>Please enter the your e-mail tied to your user:</p> <p><input name='email' type='text' class='email'/></p> <p><input name='submit' type='submit' value='Login' /></p> </form> </div> </div> </body> </html> "; } } else { echo "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.1//EN' 'http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd'> <html xmlns='http://www.w3.org/1999/xhtml'> <head> <title>Lörk(source) - Forgot your usename and/or password?</title> <meta name='Robots' content='NOINDEX' /> <meta http-equiv='Content-Type' content='text/html; charset=utf-8' /> <link href='admin/admin.css' rel='stylesheet' type='text/css' media='all' /> </head> <body> <div id='wrapper'> <div id='login_form'> <form action='remind.php?mailed=yes' method='post'> <p>Please enter the your e-mail tied to your user:</p> <p><input name='email' type='text' class='email'/></p> <p><input name='submit' type='submit' value='Login' /></p> </form> </div> </div> </body> </html> "; } ?> If you have any questions regarding the code, please just ask and il do my best to answer thanks in advance
  13. Thanks for your help This is now solved ^^
  14. the variable sent to the DB is escaped because we saw that in the var dump yes? So that means that can't be done SQL injection with using " ' chars yes? But if everything was done right, shouldn't there for all purpose and being, be a escape slash in the DB content aswell? Im writting this small CMS for a school project, so really want to make sure it's safe from SQL injection using " ' as i stated in my turn paper
  15. Thank you so much for that good piece of code Never known about it ^^ But returns the following So it is really escaping it, but when i look at what has been inserted into the DB on previous occations, it's not escaped... :-/ Database dump:
  16. Yes there is a open connection to the database, it's defined in a external config.php file and closed in the footer.php file after the above code is parsed, so im 100% that isn't the problem In regards to your var_dump.. im not really sure what that command does, so I will try and have a look at it and see if it gets me anywhere
  17. Hi PHPfreaks I am having some trouble with a form not escaping dangerous chars like " ' It did it once, but for some strange reason it no longer does it, and I am afraid that I have stared myself blind on the problem So I am hoping that some of you might like to view my code and maybe see where I am going wrong? It would really be appreciated PHP file with form: echo "<div class='comment_form'> <h3>New Comment</h3> <form enctype='multipart/form-data' action='insertcomment.php?itemid=".$itemid."' method='post'> <p class='form_name'>Name:</p> <p><input type='text' class='name_field' name='comment_name' /></p> <p class='form_code'>Security Code:</p> <p><img src='captcha.php' alt='Captcha Image' class='captcha'/><input name='anti_spam_code' class='small_name_field' /></p> <div class='form_content'> <p class='form_content'>Comment:</p> <p><textarea class='content_field' name='comment_content' rows='1' cols='1'></textarea></p> </div> <p> <input type='submit' class='form_submit' value='Post Comment' /> </p> </form> </div>\n"; Insertcomment.php <?php include("config.php"); // Get the itemid of the post $itemid = mysql_real_escape_string($_GET['itemid']); @session_start(); // start session if not started yet if ($_SESSION['AntiSpamImage'] != $_REQUEST['anti_spam_code']) { // set antispam string to something random, in order to avoid reusing it once again $_SESSION['AntiSpamImage'] = rand(1,9999999); // here you add code to let user know incorrect code entered echo "<script type='text/javascript'>document.location.href='singlepost.php?itemid=".$itemid."&captcha=false'</script>"; die(); } else { // set antispam string to something random, in order to avoid reusing it once again $_SESSION['AntiSpamImage'] = rand(1,9999999); // everything is fine, proceed with processing comment //This gets all the other information from the form $name = mysql_real_escape_string($_POST['comment_name']); $content = mysql_real_escape_string($_POST['comment_content']); $comment="INSERT INTO ". $db_prefix ."comments (post_id, comment_name, comment_content, comment_date) VALUES ('" . $itemid . "','$name','$content',CURDATE())"; // Execute query to create tables mysql_query($comment,$con); // Writes that the upload was succesfull echo "<script type='text/javascript'>document.location.href='singlepost.php?itemid=".$itemid."&captcha=true'</script>"; die(); } ?> it's these two that aren't being escaped: $name $content In advance.. thank you If you want to give it a go you can find a test install at http://lork.johns3n.net the files posted above are the comment system!
  18. Solved it myself after much trial and error it was the "yes" in my tables that were causing it to malfunction.. if i simply use 0 as No and 1 as Yes instead of text.. the problem is solved SELECT ".$tbl_name.".*, COUNT(post_id) as `commentCount` FROM ".$tbl_name." LEFT JOIN ".$db_prefix."comments ON ".$tbl_name.".id = post_id WHERE ".$tbl_name.".is_frontpage = 1 GROUP BY ".$tbl_name.".id ORDER BY ".$tbl_name.".id DESC
  19. Hello PHPFreaks This is really a straight forward question, which i am sure that you can solve in no time? I have this MySQL string: SELECT lork_posts.*, COUNT(post_id) as `commentCount` FROM lork_posts Left Join lork_comments ON lork_posts.id = post_id GROUP BY lork_posts.id ORDER BY lork_posts.id DESC But i need to modify it a little, because i made a new table row called is_frontpage, so i am thinking that i need WHERE syntax somewhere? This is the string i wrote: WHERE lork_posts.is_frontpage = Yes I tried messing around with in Phpmyadmin but was unable to come up with a working string But i hope you guys can help, as i can't help think it must be a straight forward thing xD
  20. Pagination works still! Hehe well this dude here is thanking you for having that free time help me out here! been sweating with this for a long time now! Thanks alot mate!
  21. Buddski you sir! are a god! Thanks alot for the help mate! Really appreciate it! (maybe I should check if the pagination still works ^^)
  22. Hehe would do you know it worked The counting is correct now! BUT! Another problem just occurred now sadly The id value for the links (" . $row['id'] . ") is no longer accurate and not sending you to the correct singlepost.php anymore echo "<div class='post_title'><h2><a href='singlepost.php?itemid=" . $row['id'] . "' title='" . $row['title'] . "'>" . $row['title'] . "</a></h2></div>"; echo "<div class='post_author'><p>Written by: " . $row['author'] . "</p></div>"; echo "<div class='post_date'><p>Posted: " . $row['date'] . "</p></div>"; echo "<div class='post_entry_content'><p>" . $row['content'] . "</p></div>"; echo "<div class='post_comments'><a href='singlepost.php?itemid=" . $row['id'] . "#comments' title='Click here to view comments'>". $row['commentCount'] ." Comments</a>"; *Sigh* It's always something ^^ But I really appreciate you helping me out here mate
  23. Unfortunately it didn't, same problem still however I read over your new SQL query and you wrote "COUNT(post_id) as `commentCount`FROM $tbl_name" However $tblname is my ".$db_prefix."posts table, which doesn't contain a value called "post_id" I supplied my DB structure below if it's any help ".$db_prefix."posts id INT (Primary) title (varchar 250) content (text) date (varchar 250) author (varchar 250) ".$db_prefix."comments id INT (Primary) post_id INT comment_name (varchar 250) comment_content (text) comment_date (varchar 250) Now the Post_id in the comments table are matching to Id of the post, that the comment is "tied" with
  24. Tried what you suggest and it gave me "a error" I have seen before where it renders the page, but every blog post is missing. Supplied the updated code: <?php // Selects the Blog Posts table $tbl_name="". $db_prefix ."posts"; // Defines how many adjacent pages should be shown on each side on the pagination module $adjacents = 3; // Gets the total number of rows in data table. $query = "SELECT COUNT(*) as num FROM $tbl_name"; $total_pages = mysql_fetch_array(mysql_query($query)); $total_pages = $total_pages[num]; // The file which should include the Pagination Module (Always the name of the file this code appears in ex. Index.php) $targetpage = "index.php"; // Defines the number of Blog Posts to show on each page $limit = 4; $page = $_GET['page']; if($page) // Defines the first item to display on this page $start = ($page - 1) * $limit; else // If no page variable is given, set start to 0 $start = 0; // Get Blog Post data from MySQL database $sql = " SELECT *, COUNT(post_id) as `commentCount` FROM $tbl_name Left Join ".$db_prefix."comments ON id = post_id ORDER BY id DESC LIMIT $start, $limit"; $result = mysql_query($sql); //$sql = "SELECT * FROM $tbl_name ORDER BY id DESC LIMIT $start, $limit"; //$result = mysql_query($sql); // Setup variables for Pagination Module. (DO NOT EDIT THESE!) if ($page == 0) $page = 1; // If no page var is given, default to 1. $prev = $page - 1; // Previous page is page - 1 $next = $page + 1; // Next page is page + 1 $lastpage = ceil($total_pages/$limit); // Lastpage is = total pages / items per page, rounded up. $lpm1 = $lastpage - 1; // Last page minus 1 // Apply the variables and output the pagination Module. // (We're actually saving the code to a variable in case we want to draw it more than once.) $pagination = ""; if($lastpage > 1) { $pagination .= "<div class=\"pagination\">"; // Previous Button if ($page > 1) $pagination.= "<a href=\"$targetpage?page=$prev\">« Previous</a>"; else $pagination.= "<span class=\"disabled\">« Previous</span>"; // Pages if ($lastpage < 7 + ($adjacents * 2)) { for ($counter = 1; $counter <= $lastpage; $counter++) { if ($counter == $page) $pagination.= "<span class=\"current\">$counter</span>"; else $pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>"; } } // Enough pages are detected to start hiding some in the Pagination Module elseif($lastpage > 5 + ($adjacents * 2)) { // Close to beginning in Pagination Module: hide only later pages if($page < 1 + ($adjacents * 2)) { for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++) { if ($counter == $page) $pagination.= "<span class=\"current\">$counter</span>"; else $pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>"; } $pagination.= "..."; $pagination.= "<a href=\"$targetpage?page=$lpm1\">$lpm1</a>"; $pagination.= "<a href=\"$targetpage?page=$lastpage\">$lastpage</a>"; } // In the middle of the Pagination Module: Hide some pages front and some back elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2)) { $pagination.= "<a href=\"$targetpage?page=1\">1</a>"; $pagination.= "<a href=\"$targetpage?page=2\">2</a>"; $pagination.= "..."; for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++) { if ($counter == $page) $pagination.= "<span class=\"current\">$counter</span>"; else $pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>"; } $pagination.= "..."; $pagination.= "<a href=\"$targetpage?page=$lpm1\">$lpm1</a>"; $pagination.= "<a href=\"$targetpage?page=$lastpage\">$lastpage</a>"; } // Close to end of the Pagination Module: Hide only earliere pages else { $pagination.= "<a href=\"$targetpage?page=1\">1</a>"; $pagination.= "<a href=\"$targetpage?page=2\">2</a>"; $pagination.= "..."; for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++) { if ($counter == $page) $pagination.= "<span class=\"current\">$counter</span>"; else $pagination.= "<a href=\"$targetpage?page=$counter\">$counter</a>"; } } } // Next Button if ($page < $counter - 1) $pagination.= "<a href=\"$targetpage?page=$next\">Next »</a>"; else $pagination.= "<span class=\"disabled\">Next »</span>"; $pagination.= "</div>\n"; } ?> <?php /*$num_query = "SELECT ". $db_prefix ."posts.id,". $db_prefix ."posts.title,". $db_prefix ."posts.content,". $db_prefix ."posts.date,". $db_prefix ."posts.author, COUNT(". $db_prefix ."comments.id) AS numComments FROM ". $db_prefix ."comments INNER JOIN ". $db_prefix ."posts ON ". $db_prefix ."comments.post_id = ". $db_prefix ."posts.id GROUP BY ". $db_prefix ."posts.id, ". $db_prefix ."posts.title,". $db_prefix ."posts.content,". $db_prefix ."posts.date,". $db_prefix ."posts.author"; $num_result = mysql_query($num_query); while($num_row = mysql_fetch_assoc($num_result))*/ // This is where the HTML output of our Blog Posts is generated while($row = mysql_fetch_array($result)) { echo "<div class='post_entry'>"; echo "<div class='post_title'><h2><a href='singlepost.php?itemid=" . $row['id'] . "' title='" . $row['title'] . "'>" . $row['title'] . "</a></h2></div>"; echo "<div class='post_author'><p>Written by: " . $row['author'] . "</p></div>"; echo "<div class='post_date'><p>Posted: " . $row['date'] . "</p></div>"; echo "<div class='post_entry_content'><p>" . $row['content'] . "</p></div>"; echo "<div class='post_comments'><a href='singlepost.php?itemid=" . $row['id'] . "#comments' title='Click here to view comments'>". $row['commentCount'] ." Comments</a>"; echo "</div>"; } mysql_close($con); ?> The "while" in "while" statement I made first, is the closest I have been to success so far
  25. Damn I feel like moron at the moment! >< This was indeed to problem that made it crash! Thank you! I'm sorry Buddski, I completely missed you pointing this out to me in your post! Sorry! Somebody should seriously revoke my pass to code after this! ^^ This is now solved!
×
×
  • 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.