Jump to content

Erik_Fischer

Members
  • Posts

    11
  • Joined

  • Last visited

Erik_Fischer's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I ran the fetch_all statement and it came back as false. What should I do to get mysqlnd working now that we know this?
  2. I just moved all of my website files and databases over to a webhost and I've run into the following error when trying to run one of my pages: Call to undefined method mysqli_stmt::get_result() I saw this problem before and it had something to do with the mysqlnd driver not being installed. So I contacted the web host and they said that both mysqli and mysqlnd were installed by using the following PHP: <?php if (extension_loaded('mysqlnd')) echo 'extension mysqlnd is loaded'; // WORKED if (extension_loaded('mysqli')) echo 'extension mysqli is loaded'; // WORKED ?> And here's the PHP I'm trying to run: <?php $cxn = mysqli_connect("localhost", "my_username", "my_password", "my_database") or die ("Couldn't connect to the server. Please try again."); $id = 0; $stmt = $cxn->prepare('SELECT value FROM test WHERE id = ?'); $stmt->bind_param('i', $id); $stmt->execute(); $result = $stmt->get_result(); echo $result->num_rows; ?> Please help!
  3. So I've done some researching on hierarchical data. My question if, since this is a comment system and there can be thousands of replies to a post (meaning trees that could have a height of 1000+), how slow would things become? Also, with nested sets, wouldn't that mean I would have to update the entire tree's left and right values every time a new reply is made?
  4. I've added a diagram to make it more clear how the system works.
  5. Thanks for the reply, however, if I'm correct in saying that "thread_id" is basically my "parent_id", right? If so, that would only return the total replies to the parent_id (thread_id), whereas I need it to show the total replies to the parent_id, and each individual reply made to that post. For example, if we have a post (let's say an id of 1). If I reply to that post, then the total number of replies to it will be 1. If I reply to the reply of that post, then the total number of replies to the post will be 2 and the total number of replies to the reply will be 1. Furthermore, if I reply to the reply of the reply of that post, then the total number of replies to the post will be 3, the total number of replies to the reply will be 2, and the total number of replies to the reply of the reply will be 1. And so on. What you've suggested only accounts for the parent_id's (thread_id's) total replies. :/
  6. In my database, I have the following structure for posts: post_id | reply_to | parent_id 1 1 1 2 1 1 3 2 1 4 3 1 What I want to do is add another column that keeps track of the total number of replies to a post. So in the end, the table would look something like this: post_id | reply_to | parent_id | total_replies 1 1 1 3 2 1 1 2 3 2 1 1 4 3 1 0 If you don't understand the logic, let's take post id 4. Post id 4 is a reply to post id 3 which is a reply to post id 2 which is a reply to post id 1. That means that there are a total of 3 replies to post id 1. Using the PHP values $post_id, $reply_to, and $parent_id, how would I create a query that would increment the total number of replies when someone makes a new reply to a post? So for example, if I replied to post id 4, how would I increment all of the necessary numbers so that it would look like this: post_id | reply_to | parent_id | total_replies 1 1 1 4 2 1 1 3 3 2 1 2 4 3 1 1 5 4 1 0 (this is the new reply) Thanks.
  7. I'm trying to create a comment section for my website and need to make it so that after the person submits a comment (and it contains errors), it will show the error (a new HTML element) without refreshing the page. I know almost nothing of AJAX/JQuery, so I'll need some help. Here's what I have so far: <?php if(isset($_POST['reply_submit'])) { $reply = $_POST['new_reply']; $reply_message = ""; if(empty($reply)) { $reply_message = "Your comment is too short."; } } ?> <html lang="en"> <body> <form class="no-margin" method="POST" action=""> <textarea name="new_reply" placeholder="Write a reply..."></textarea> <button name="reply_submit" class="btn post-button" type="submit">Post' . (isset($reply_message) ? '<div class="comment-warning">' . $reply_message . '</div>' : '') . '</button> </form> </body> </html> So what I need it to do is, if the person's comment box doesn't meet the criteria (in this case, an empty field), I need it to show this error line without refreshing the page: <button name="reply_submit" class="btn post-button" type="submit">Post' . (isset($reply_message) ? '<div class="comment-warning">' . $reply_message . '</div>' : '') . '</button> Please help.
  8. I'm making a registration page and need to check if the username entered in the form is a username that already exists in the database. How is this done?
  9. Gotcha. However, when I test it out and submit, nothing happens, it doesn't show the message.
  10. Just wondering, how come something like this isn't working for me: HTML: <form method="POST" action="submit.php"> <fieldset> <label>Username</label> <div class="form-group"> <input name="username" class="span-default" type="text" placeholder="Choose a username"> <?php if(isset($message)) { echo '<div class="form-warning">$message</div>'; } ?> </div> </fieldset> </form> PHP: $username = $_POST['username']; $message = ""; if(empty($username)) { $message = "Field is empty. Try again."; }
  11. I'm trying to create a signup page and am currently working on the verification of input (checking if they're empty, etc). I'm handling the PHP in a separate file (the action file) when the form is submitted: <form method="POST" action="submit.php"> <fieldset> <label>Username</label> <div class="form-group"> <input name="username" class="span-default" type="text" placeholder="Choose a username"> </div> </fieldset> </form> What I need to do is add the following code under the input tag shown above if an error is found: <div class="form-warning">ERROR TEXT HERE</div> This is a portion of my PHP code. How would I do what I specified above from a separate file (or is there a better way)? $username = $_POST['username']; if(empty($username)) { // action here } Please help.
×
×
  • 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.