Jump to content

justsomeguy

Moderator
  • Content Count

    31,575
  • Joined

  • Last visited

  • Days Won

    77

Everything posted by justsomeguy

  1. There are several problems there, still. For the fifth time, you're missing a semicolon. Again, the first opening bracket doesn't have a matching closing one, so figure that out. If the person is not logged in, what do you specifically want to do? Which lines of code should be executed if the person is not logged in? Figure it out and add the missing bracket. When you're checking if it's a post request, you're missing your brackets. A try block should have brackets. Again, missing. And, again, the try/catch block is completely unnecessary and won't impact how the code run
  2. Probably not automatically through .NET (it is .NET, not IIS, that manages session state), but I suppose you can figure out where it stores them and look them up that way. I don't know why that's necessary though, this is all handled automatically. When the session times out it is deleted. I don't know how .NET handles sessions specifically, but I imagine that if you try to start a session then it will either look for an ID for an existing valid session, or start a new empty session otherwise. Your web service can have some method that can look at the session to determine if it is a new em
  3. I guess I don't understand why you're not setting the value initially, I don't understand what the barrier to doing that is. How about just calling the reset function when the thing loads? That's what I'm talking about for the reset button doing the same thing as when it initially loads.
  4. Well, how are you generating and storing the ID in the first place? It seems pretty trivial to store a piece of data in a certain place and then check the same place to see if that data is there or not, I'm not sure what you're missing.
  5. Insert queries do not have a WHERE clause, ever. A WHERE clause is for filtering. You do not filter an insert. Well, the first step is to fix your syntax errors. After that you can work on getting the logic right once the code actually runs.
  6. Are you saying you don't set the value unless the reset button is pressed? It seems like the reset button should just repeat the exact same action that set it up in the first place, why is it doing something different? What's the difference between initially setting up the form and resetting it?
  7. The type attribute is just for native validation or adding helpful controls (like a date picker), but according to MDN the value property is always a string: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement
  8. .NET should handle that automatically, or is this some ID that you're creating and managing yourself?
  9. There was only one missing opening bracket in your code, all of the other bracket issues were caused by no matching closing bracket. The solution for a missing closing bracket isn't to remove the opening bracket, it's to figure out where the closing one should go. That's why I pointed out that your solution above to remove the unmatched opening bracket was not the correct solution. Also, the syntax error about the unexpected variable is not about brackets at all. No, that does not seem like the right place to add one. Although the entire logic of having that query there and
  10. If you want to do that in PHP, this might be all you need: https://www.php.net/manual/en/function.getimagesize.php
  11. The global scope is always available if that's what you're asking about. If it's a question of timing instead of scope then whatever code sets the value should then execute the function that uses it. Or, maybe some flag that says whether or not the values are loaded and if the function that uses those values sees that they're not loaded then it runs whatever code loads the values before trying to use them. This is all pretty abstract though.
  12. The general reason is that the variables are out of scope or undefined when the code runs. The specific reason depends on the specific code.
  13. No it wouldn't, which is why I was confused when you said it reported no more errors. There are several more errors.
  14. justsomeguy

    where not

    Use the not equal operator in place of the equal operator.
  15. If all I do is remove that one bracket, it still just shows the next error it finds: Error: There is 1 more closing curly braces '}' found This count is unaware if curly braces are inside of a string PHP Syntax Check: Parse error: syntax error, unexpected '$q' (T_VARIABLE) in your code on line 17 You're not pasting individual blocks or lines, right, you're checking the entire file at once? PHP checks the entire file at once before executing it. If you're not doing the same, you're not doing it right. The individual lines of code in your file do not live in a vacuum, they a
  16. Well, yeah, that's going to eliminate a syntax error, but I'm pretty sure you've added a runtime error that you'll see whenever you get the code to actually execute. What "PHP checker" are you using?
  17. This is what happened when my IDE tried to reformat your code: <?php # Access session. session_start(); # Open database connection. require('connect_db.php'); # DISPLAY COMPLETE LOGGED IN PAGE. # Redirect if not logged in. if (!isset($_SESSION['user_id'])) { require('login_tools.php'); load() # Retrieve selective item data from 'images' database table. $q = "SELECT * FROM images WHERE id = $id"; $r = mysqli_query($dbc, $q); if (mysqli_num_rows($r) == 1) { $row = mysqli_fetch_array($r, MYSQLI_ASSOC); if ($_SERVER['REQUEST_METHOD'] == 'POST') $name = $_
  18. justsomeguy

    sql query isuue

    They use different formats for dates.
  19. Like I said, the opening bracket before require does not have a closing bracket, and you're missing a semicolon. I am not talking about parentheses, I'm talking about curly brackets. Your computer does not have a finite supply of newline characters, format your code so that it's easy to read. There's no prize for having the fewest lines of code. if (!isset($_SESSION['user_id'])) { require('login_tools.php'); load() What is missing from this picture? It should be pretty obvious.
  20. Well that's remarkably light on details, although it's probably worth pointing out that the president of the US is not a dictator. It would also be pretty surprising if any world government decided to take out ad space on a programming website.
  21. Practice. Pick a technology, learn how to use it, and start making things.
  22. Yeah, that's the line. Does that opening bracket before require have a matching closing bracket? Because it looks to me like your code has 8 opening brackets and 6 closing brackets. Don't you think those should be the same number? You need to find the missing ones and add them where they are supposed to be. And how about that call to the load function? Every statement should end with a semicolon, right? Well, where is it? More importantly, why don't you notice these things? That's the reason. Maybe you are. But you must. always. write. code. correctly. There i
  23. Here's your actual error message: Parse error: syntax error, unexpected '$q' (T_VARIABLE) on line 15 Like I said, your code is full of syntax errors. That error message has absolutely nothing to do with $q or what it's set to or anything else. It means that when PHP gets to line 15 it sees you trying to set a variable and that doesn't make sense, because of (multiple) syntax errors on the previous line of code. You're missing opening brackets, you're missing closing brackets, you're missing semicolons, and none of your code is going to run - at all - until you fix them. I've said
  24. I see 3 syntax errors in your code that will stop anything from running, and 2 runtime errors that will cause problems if you actually get it to run. To start with, count the opening and closing brackets. Those should be the same number. Yeah, you've got several syntax errors in that too. You've got commas where they shouldn't be, and missing commas where they should be. Even that has syntax errors. You've got an opening double quote, where's the double quote to close the string? And the SQL query in your PHP has 2 syntax errors. There's only 9 words in it.
  25. I don't see any issues, as far as I'm aware that should work fine.
×
×
  • Create New...