Jump to content

justsomeguy

Moderator
  • Posts

    31,575
  • Joined

  • Last visited

  • Days Won

    77

Everything posted by justsomeguy

  1. It's not a reserved variable, you overwrote it: $browser = $browser['browser'];
  2. Print $_SERVER['PHP_SELF'] to see what it's set to, use that to figure out what to check for.
  3. justsomeguy

    Remove data

    That's not the same code you posted for the other page. Post the complete file that you're working on, not only part of it.
  4. justsomeguy

    Remove data

    I don't think you're understanding what I said. An if statement has 2 parts - the condition, and what to do if the condition is true. if (condition) { do this } Look at your code again. You have the if statement checking if the user ID is in the session, but what does it do if it's not? Look at the code and tell me what it's going to do if the user is not logged in. The comment right before the if statement says to redirect if they're not logged in. But you must have forgotten to add the actual code to redirect them, because the only thing you have is an if statement. The end result of that code is that it will only process the uploaded file if the user is not logged in. That seems like a weird rule. Didn't you say that you wanted a button or link to trigger the delete? That's what your if statement should check for - did they click on that.
  5. The now function returns a date, if that is an integer column then you should use the unix_timestamp function and just subtract the number of seconds.
  6. justsomeguy

    Remove data

    # Redirect if not logged in. if ( !isset( $_SESSION[ 'user_id' ] ) ) What are you doing with that code? You have an if statement there. If that is true, then what happens? All you have is an if statement. The way you have your code structured, PHP considers the if statement which follows that to be whatever you want to do if the above if statement is true. So you are telling it to only process the uploaded file if the user is not logged in. What's the point of that? Are you just copying and pasting bits of code around without knowing what they do? if (empty($errors)) { $q = "DELETE FROM users WHERE $user_id='Alfreds';"; $r = mysqli_query($dbc, $q); Unless a variable called $errors has a truthy value, you're either going to delete every user or no user depending on whether or not $user_id is set to "Alfreds". If it is, then you'll delete every user. And you always run that code unless $errors is set and has a truthy value.
  7. justsomeguy

    Remove data

    Of course it's possible. Like the page on deleting shows, if you want to delete a particular row in the database you need to be able to uniquely identify that row in the SQL query. So, pass whatever unique identifier you're using to a page that can get the ID and delete the corresponding row. You can put the ID in the link in the button if you want to, or create a form and pass it that way (a dropdown to select a user to delete, or however else you want to do it). I wouldn't recommend using that file upload code, the $_FILES array contains an error code which the code above doesn't check. http://php.net/manual/en/features.file-upload.post-method.php http://php.net/manual/en/features.file-upload.errors.php
  8. justsomeguy

    Remove data

    The only thing the code you posted does is (badly) process an uploaded file. If your question doesn't have to do with uploading files, why did you post that code? What does that code have to do with whatever else you're asking?
  9. I wasn't suggesting learning C, but if you want to understand what happens when you run a program on the command line, looking that up will help you understand that. On a command line you type the name of the application to run, and then whatever options or parameters you want to send, and the application will have access to those. That's all you're seeing in the command there.
  10. I don't know what you're trying to do. Are you trying to show how much time has elapsed from a date in the past instead of how much there is until a date in the future?
  11. What specifically are you looking for other than the column name? What's the other condition in the where clause that you're trying to check?
  12. No, you're just checking for a referer header.
  13. Those are just parameters that get passed to the console application. When the shell executes the console application, it passes all of the command-line parameters to it. One parameter will be "core:archive" and the other will be the --url parameter. It will also have the entire command available. Look up argv and argc in C for a general description about how that works. https://developer.matomo.org/guides/piwik-on-the-command-line
  14. If you want to change the conditions, maybe you can use the information in $_SERVER to help you test what you want to test.
  15. Anything running on the command line can include that file without a problem.
  16. On our servers, I use this: $php_command_line = strpos(php_sapi_name(), 'apache') === false && (strpos(php_sapi_name(), 'cgi') !== false || strpos(php_sapi_name(), 'cli') !== false); Then I can check if $php_command_line is true to figure out if it is a command-line execution or if it's being executed through the web server. The above line probably won't work for you unless your web server is configured like ours, but use php_sapi_name to see what it returns when you run the page in a browser versus on the command line. You might be able to check for other differences also: http://php.net/manual/en/features.commandline.differences.php For example, obviously PHP wouldn't look for cookies on a command line, but I don't know if that means that $_COOKIE is always empty, or if it doesn't exist at all.
  17. No, you're not right. There is no condition, and there is no increment. It is looping through members of a set. In this case, the set is the set of integers from 0 through 9. Maybe it will help you understand if you look at it in array syntax instead of using the range function: for i in [0,1,2,3,4,5,6,7,8,9] Looking at that, why would i ever be 10? Look at another example: for i in ["A", 3, 9, "Cat", 4, 100] Would you look at that, and say that after the loop i is going to be 101? Because that doesn't make sense. i is not going to be set to a value that is not in the set. The only thing that range does is return an array of numbers within a range. There is no condition in the loop, and there is no increment (other than changing an internal array pointer to point to the next element in the array).
  18. That's from the MDN documentation. https://developer.mozilla.org/en-US/docs/Web/CSS/gap
  19. Range just returns a list of numbers from min to (max - 1). Or, 0 through 9. So, i is each number from 0 through 9. You're not telling it to keep adding 1 to i, you're just telling it to loop for each number from 0 through 9.
  20. There are several ways to send email. The most basic is the built-in mail function, but classes like PHPMailer are more useful.
  21. https://www.w3schools.com/python/python_functions.asp
  22. Here's the documentation: https://devzone.advantagedatabase.com/dz/webhelp/Advantage9.1/string_functions.htm
  23. It doesn't, that code does not send an email. It just prints what was submitted.
×
×
  • Create New...