Jump to content

Epicballzy

New Members
  • Posts

    7
  • Joined

  • Last visited

Epicballzy's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I got it fixed.. ^ Helped me out, so thanks for that. I'll keep that in mind for next time. My code actually had some variables mixed up. I'm using pagination, so I actually need 2 variables in the header. 1 for the page id (pagination) and one for the actual post and such. I was using the page id to get the comments instead of the post id. But anyways, thanks a lot for the helpful tip!
  2. Hello, I've been working on rather simple comment system and when I try and grab all the comments that are "connected" to a post, I receive the Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000] error. The full error: Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-5, 5' at line 1' in C:\xampp\htdocs\post\index.php:90 Stack trace: #0 C:\xampp\htdocs\post\index.php(90): PDO->query('SELECT * FROM c...') #1 {main} thrown inC:\xampp\htdocs\post\index.php on line 90 My code: $start = 0; $limit = 10; if(isset($_GET['p'])) { $id = $_GET['p']; } else { redirect("/"); } $start = ($id - 1) * $limit; $query = $database->query("SELECT * FROM comments WHERE post_id = '$id' ORDER BY date DESC LIMIT $start, $limit"); while($row = $query->fetch()) { $author = $row['author']; echo $author; } I honestly don't understand why this isn't working. I've used the exact same syntax for my post section on my website. If anything else is needed, just let me know. Thanks for the help!
  3. I was just stating that that's how I do it. Not with the ORDER BY. Here's how I did it with the ORDER BY: $sql2 = mysql_query("SELECT * FROM posts ORDER BY date DESC $limit"); DESC or no DESC.. It hasn't worked.
  4. I have added the ORDER BY, but nothing has changed. The way I'm displaying the data, is using a while loop, gathering everything about the row in the database, and displaying select fields from an array. Would that have an affect on the ODER BY? This is what I do: $sql2 = mysql_query("SELECT * FROM posts $limit");//$limit if for my pagination while($row = mysql_fetch_array($sql2)) { $post_data = $row; $title = $post_data['title']; $content = $post_data['content']; $author = $post_data['author']; $post_id = $post_data['post_id'];?> //Then I add the variable in divs/header tags }
  5. I have a posting system worked out, as well as my database configured to my linking.. But as of right now, my posts are posted from oldest to newest, having users scroll down or go to the next page to see the most recent post. How would I "flip" that around and make my posts start from newest to oldest by its date/time (Which is stored in the database)? Thanks!
  6. I removed the $_SERVER['SCRIPT_NAME'] and it worked. Thanks you!
  7. I'm trying to learn php, and I've picked up a php/mysql member system type script, and I'm trying to put the login/sign-up forms into my own pages. The problem I'm having though is getting PHP and HTML to work in the same echo""; This is the like I'm getting the errors at. <form name="login" action='".$_SERVER['PHP_SELF']."' method="post" class="box login"> I've tried switching around the tags, from " to ' but that didn't work. Any suggestions?
×
×
  • 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.