Jump to content
#StayAtHome ×


Staff Alumni
  • Content Count

  • Joined

  • Days Won


mac_gyver last won the day on February 14

mac_gyver had the most liked content!

Community Reputation

464 Excellent


About mac_gyver

  • Rank
    Staff Alumni

Profile Information

  • Gender
    Not Telling

Recent Profile Visitors

147,689 profile views
  1. what result or symptom are you getting that leads you to believe that? btw - the short opening php tags <? my not be enabled on your server. you should ALWAYS use full opening <?php tags. You can also use a combined opening/echo tag <?=
  2. this logic should NOT be combined in one statement. here's why. this code is trying to process a form submission. the visitor who was presented with the form and submitted it expects the form processing code to run or to be told exactly why it didn't. these session variables are inputs to the process and must be validated, along with validating the form data, before actually using the form data. each condition that will prevent the form processing code from running should result in a unique and helpful error message being setup and displayed telling the visitor why the submitted form was not processed. for those things that the visitor has control over, he can correct, then go through the process of submitting the form again. if the process is in a state where no further forms of the type that was submitted can be processed, the error message should indicate this. your form processing code should - detect if a post method form has been submitted. if there is more than one type of form, detect which form was submitted. trim all the form data, so that you can detect if all white-space characters where entered. validate all the input data, setting error messages in an array, using an array index indicating the input the error corresponds to. you would display the contents of the errors array at the appropriate point in the html document. if there are no errors (the array holding the error messages is empty), use the submitted form data. btw - once a form has been submitted, except for unchecked check boxes and radio buttons, all form inputs will be set. there's no good reason to have isset() tests for these type of inputs as this will just hide programming mistakes.
  3. the OP solved this on another forum.
  4. the associative index for the COUNT(*) expression is actually something like $row['COUNT(*)']. to simplify this, add an alias name for the COUNT(*) expression in the query and use that alias name for the associative index. next, both of the query examples you have shown will/probably match at most one row. why you are using a loop to fetch the data. just fetch the single row without the loop.
  5. what do you want the output to actually be? where do you want to show the totals and do you really want to repeat all the id/name/designation information?
  6. in addition, you need to always have error handling for database statements. if you had, you would know that the query is failing, with an error about a non-existent column of the same name as the session variable value. also, using a prepared query would have eliminated the problem, since you would not be trying to put data directly into the sql query statement.
  7. if you are asking about the value zero in the ['error'] element, that means the upload was successful, which you would know by making use of the php.net documentation on uploading files. your existing code should be testing for that value before using any of the uploaded file information and reporting back to the user that the upload failed for any of the other possible values. for the posted print_r() output, if the code 'isn't working', the problem is something else. do you have php's error related settings setup so that all php errors will get displayed or logged?
  8. data related to the user should use the user's id (auto-increment integer primary index from the 'user' table') to relate it back to the user it belongs to. this will result in the least amount of data storage, result in the fastest queries, and allow the user's information (name, username, ...) to be edited without breaking the relationship in the data. you would also store the user's id in the session variable, not the user's name/username, when the user logs in, as this will also support editing the user's information, in addition to supporting the current operation you are asking about. to get any of the other user's information, you would query for it on any page that needs it. tbl_rides needs a user_id column that you would store the $_SESSION['user_id'] value in. also, for the operation you are asking about, if the current visitor is not logged in, you would not display the form, nor run any of the form processing code.
  9. based on the http error page, you are doing this on Windows. the .htaccess file is not keeping the leading dot when downloaded. you need to rename/copy the contents of the htaccess file to a file named .htaccess (with a leading dot.) this should allow the requested URL to get rewritten and should work.
  10. your code has no error handling for the database statements that can fail - connection, query, prepare, and execute. as a result of this, you are getting follow-on php errors, that are not where the real problem is at, because the code continues to run when one of these database statements fail. the simplest way of adding error handling for these database statements is to use exceptions for errors and in most cases let php catch and handle the exception, where it will use its error related settings to control what happens with the actual error information (database statement errors will 'automatically' get logged or displayed the same as php errors.) the exception to this rule is when inserting/updating user supplied data and you need to detect duplicate or out of range values. in this case, you code would catch the exception, detect if the error number is for something that your code can handle, then setup a message telling the user what was wrong with the data that they submitted. to use exceptions for errors for the mysqli extension, add the following line of code before the point where you make your database connection - mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); next, if you switch to the much simpler and more consistent PDO extension, over half of the php statements will go away and there's also no good reason to be concatenating multiple lines together when building the sql query statement or html content.
  11. finding a line in a php.ini file that has a value, doesn't mean that that php.ini or that line is being used (syntax errors in a php.ini stop the parsing of the following lines in the file/probably treat all the rest of the file as part of the line where the syntax error is at, w/o any error being reported), which is why i asked what a phpinfo() statement showed for the value. this is also why you need to ALWAYS have the error related settings set to report all errors and to log them on a live/public server.
  12. that's because it is using the same method and is lacking in any logging of information when the success value isn't true. do you have php's error_reporting set to E_ALL and either log_errors set to ON or temporarily (turn off when finished) set display_errors to ON, so that php would help you? while there's nothing php version specific in the code, there is something php configuration specific that could affect the code. allow_url_fopen is probably off (there would be php errors when the code runs.) what does a phpinfo() statement show for allow_url_fopen?
  13. you are probably looking for an absolute file system path, not a http URL - require $_SERVER['DOCUMENT_ROOT'] . '/r/pagevisit.php';
  14. your connection probably doesn't exist and you would be getting a bunch of php errors. you need to ALWAYS have php's error_reporting set to E_ALL and when learning, developing, and debugging code/queries, set display_errors to ON. these settings should be in the php.ini on your system. next, you need to ALWAYS have error handling for all statements that can fail. for database statements - connection, query, prepare, and execute, the easiest way of adding error handling is to use exceptions and in most cases let php catch the exception where it will use its error related settings to control what happens with the actual error information (database errors will automatically get displayed or logged the same as php errors.)
  15. use (NOT) FIND_IN_SET(str,strlist). the strlist parameter can be supplied via a single prepared query place-holder.
  • 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.