Jump to content

justsomeguy

Moderator
  • Content Count

    31,575
  • Joined

  • Last visited

  • Days Won

    77

Everything posted by justsomeguy

  1. Redirect after you process the form.
  2. What do you mean? Web servers don't "want" to do anything, they simply do what they are told to do. What specifically are you seeing? Are you sure that your issue is related to PHP? .NET is the only platform that uses the term "postback" to describe a common behavior.
  3. Right, and can you pass the exercise at the bottom of that page? It's just showing how to build a select query. That's what you need to do. You're not doing it correctly.
  4. I wouldn't say it's "useless," but you're going to end up with a SQL query that has a syntax error in it. Just look at what the query is going to be after you do that.
  5. That part of the query is fine, it's the part that follows where you add errors.
  6. What? If any arbitrary line of code works on a page that displays shopping cart information, then the same line of code belongs in any other page that uses the database? OK, if you say so. You're the programmer. Of course not, look at the SQL query you're trying to build. It's not a valid SQL query.
  7. That's right, you have a syntax error in that PHP code, and I also questioned why you were treating $_SESSION['user_id'] as an array when that doesn't seem like it would be an array. And, whether or not that foreach loop runs at all, the SQL query is also going to have a syntax error in it. If that IS an array, and let's say it has 2 values, then you've built a SQL query that looks like this: SELECT * FROM forum WHERE user_id IN (0, 1 That's not right. If it's not an array, or an empty array, then this is your SQL query: SELECT * FROM forum WHERE user_id IN ( That's not right either. So, yeah, I'm wondering why you're using that code to build a basic select query to select the data you want from the database. You shouldn't have to copy and paste code to do this, if you understand how select queries work then it should be pretty apparent how to write the query you need to get the data you're looking for.
  8. It's required if you need it, as the programmer. That's your job to figure out, you're the programmer. It doesn't matter that it's a "user", the database does not distinguish between the different "objects" that you try to store in the database. What the records mean to you does not matter, it does not change how to retrieve them. Every table in the database holds records, and getting records from a database table is the exact same regardless of what you've decided to name the table or the fields. You still use a select query. There's not a particular unique query for "getting users" versus "getting videos" or "getting comments" or whatever else. They all use the exact same kind of select query. You're the one that is making the distinction here, not the database. The database doesn't care what the records mean to you, it does not store things or retrieve things differently just because they have a different meaning to you. That's why you're not finding specific instructions about "how to add a comment" or "how to add a profile" or whatever else - the actual data does not matter, it does not change the programming. You're supposed to learn the generic principles about this and then apply it to your own situation, but you've skipped the part about generic principles and instead are trying to find tutorials or videos or whatever that relate directly to your specific situation. It's simple, and is the exact same way you display any data from the database on any other page. You use a select query to tell it what data to get, and then you display it. Do you really think the database cares that the page where you're trying to display the data is linked from "home.php?" Do you think that matters at all? Or that it's "public" (whatever that means)? Or that you're also going to be checking the session to see if someone is logged in? None of that matters.
  9. Yeah, I see that. Why did you do that? What does adding an item to a shopping cart have to do with displaying a forum? You've added a PHP syntax error and there's also going to be a SQL syntax error in that code, so none of that is going to run. Displaying records from a single database table is pretty easy, that's not something complex enough that you need to copy some other piece of unrelated code and try to change it. The changes don't make sense, you're trying to loop through $_SESSION['user_id'] like it's an array. Why would that be an array? That doesn't make sense. None of this code makes much sense, you're trying to take an unrelated piece of code and change it into something that should be easy to do by itself. I don't know, do you? You're the programmer, do you need to pass an ID of something in the URL? Does that accomplish some goal that this page needs?
  10. I'm not sure if browsers have a way to disable the developer tools or the console specifically. Probably not, because if so then any code that tries to use the console would be a fatal error and the code would stop running.
  11. It sounds like you have something that is confused about your code and thinks that the string inside your Javascript code is actually HTML code instead of a Javascript string. The bug is in whatever is giving you that message, assuming the rest of your HTML code is structured correctly (e.g., that Javascript code is inside a script element).
  12. What exactly is that code supposed to do? You're saying that code is for posting a new comment?
  13. If not even that first console.log works then it sounds like it's not running at all. If the first alert works but not console.log and not the second alert, maybe the browser that you're using does not have console.log defined.
  14. That O'Reilly book seems pretty good, 400-odd pages is about what I expect for an intro to PHP, and the reviews are generally positive. There are higher-ranked O'Reilly PHP books, but many of them deal with additional technologies like MySQL and Javascript, not just PHP. I would stay away from Amazon's #1 book in PHP programming though, which is the Kindle edition of "The Super Easy Sous Vide Cookbook: 575 Best Sous Vide Recipes of All Time".
  15. That code is from a book? Yeah, that's kind of crap, they don't bother to check the error code for the uploaded file and they're trying to use the try/catch block that is pointless. Which book did I suggest? I normally only suggest recent O'Reilly books, which I expect to contain decent code given their reputation.
  16. I'm not familiar with that specific book, I don't know if I remarked on specific code examples or if I was commenting on the particular code you were posting here. I don't have an opinion on the specific book.
  17. Then you 1) didn't do it correctly, or 2) didn't notice a different basic syntax error. I pointed out multiple syntax errors, and the presence of any one of them, again, will cause the entire thing to break. So, did you fix all of them? Did you fix the braces correctly? I don't know, and if you don't know either then that's a problem. Because in the most recent code you posted, you definitely did not, and for some reason you're still trying to use a try/catch block. Which I have no idea why. And I've told you this. This whole thing is like someone who refuses to learn the basics about the Russian language but still thinks they can call someone who only speaks Russian and ask them what time it is. I don't know why you think programming is as easy as you think it is, but it's not. You can't just skip over all of the basics and expect to be able to do anything, I don't know what other skill set is like that and why you think programming is one of them. What you're trying to do is very easy for someone who knows PHP, but you don't know PHP. Just like asking a Russian speaker for the time is very easy for someone who knows Russian.
  18. The report links are the major way to get in touch with the staff, I'm not sure what their policy is about responding though, if they have a policy.
  19. Yeah, there's nothing more that I can add. You have several books about PHP but you've never started at the beginning, you always try to jump ahead to something that you're trying to do. Maybe after a couple years of trying and failing you'll realize that doing that was not a good idea. There's nothing else to add, if you don't understand the basics you won't be able to do anything, and I don't understand your reluctance to just read from the beginning and make sure you understand everything. I really hope it's not an issue of you not wanting to spend the time to do that, because you have wasted a tremendous amount of time already trying to do things that you never bothered to learn how to do. If I point out basic errors five times and you still don't understand, then I'm not helping, and I can't help if you don't know what I'm talking about in the first place.
  20. You can do whatever you want to do in the showError function, it will get called if there's an error.
  21. There's not enough information to help you. You have a for loop there where you keep inserting the same thing, but I don't know what data is being submitted to the page.
  22. Because one of them runs in the web browser, and one of them runs on the web server. The web browser does not have console access to the web server.
  23. What code are you running on the page that scrolls? The answer is in there somewhere.
  24. Everything that the browser submits is a string, there is no data type information that gets submitted. It it just a name, and a string value.
×
×
  • Create New...