Jump to content

mac_gyver

Staff Alumni
  • Posts

    5,510
  • Joined

  • Days Won

    185

Everything posted by mac_gyver

  1. if the $departTime[$a] - $departPlace[$a] - $arriveTime[$a] are multiple segments belonging to one trip, they don't belong in any of the queries you have posted above because they belong in a separate table, such as a trip_details table, one row per segment and they use the trip log id to associate them with the trip they are part of. your trip log table should contain global/one-time information for each trip. any information for a trip where there are multiple sets for any one trip belong in a separate database table.
  2. the problem isn't the method. you are getting an upload error due to the size of the file and your php settings. see this link - http://uk.php.net/manual/en/features.file-upload.errors.php
  3. if you want to do this to learn something about OOP, i recommend creating a general purpose CRUD ( http://en.wikipedia.org/wiki/CRUD ) database class using pdo prepared queries. you would then call the methods of this class from your application to run the queries you have shown in your code. you would form the queries and an array of the data types/values in your application code and pass them into the CRUD class methods. the Create (insert) method would be for running an INSERT query.
  4. the code i posted in reply #3 would have helped determine why the tmp_name is empty. did you try that code?
  5. @Q695, sorry to pick on more of your replies, but the OP already has an upload script. he needs help finding out why it produces an error when trying to copy the uploaded file. posting a link to an upload tutorial with code that is no better than what the op has now, isn't specific to the problem.
  6. shared web hosting would allow you to use a local php.ini also, if the code acts like it doesn't have a fatal parse error in the main file, you can set php's error_reporting/display_errors in the code. edit: the only obvious thing wrong with the code now is you are not using the $find variable in the queries. you have the literal string find (missing the $ to make it the variable.)
  7. the code you posted isn't running the insert query, unless you didn't post all the relevant code.
  8. @Q695, a number of your replies in threads have nothing to do with the problem in the thread. are you even reading and understanding what is being asked?
  9. mikk809h, Phear showed you some troubleshooting logic in the hope that you would show us the output from it so that we could see how your submitted data is organized. you still haven't shown how you are submitting multiple sets of data, so you haven't gotten anywhere with this problem. you either must use an array name for your form fields (preferred method as it allows any number of data items in the set) or give each one a unique name (not preferred as it takes more code to keep track of the unique names).
  10. the reply by Q695 has nothing to do with your problem. it's not even where the error is occurring at.
  11. your select query is failing due to an sql (mysql) syntax error. you need to echo mysqli_error($con); to find out why. if i'm not mistaken, your food column contains strings and the $food variable/value needs to be enclosed in single quotes so that it is treated as a string - '$food'
  12. until you define what you mean by "multiple strings/keys" and then share that definition or a diagram with us, we cannot help you.
  13. your overall code, based on what you did post, has queries inside of loops inside of other loops... that's a bad design because - 1) running queries inside of loops take a lot longer than running a single query once. you can probably write one query using JOINs and simply have one loop to do everything you are trying to do. 2) it takes more code, so it is harder for you to see what your code is doing. without seeing what your code really is, best guess why you only get the last value is you are initializing that variable inside of the loop where that code is running and it is being set to zero every pass through the loop.
  14. don't give the user a choice on how to enter the date. use three specific select/option menus for the year, month, and day (add a date picker pop-up if desired to set the three select/option values.) then all you need to do is make sure the entered date is an actual date.
  15. i think you are making this harder than it is. if you are trying to sum value(s) that are present inside of your display loop, just initialize the total variable to zero before the start of the loop, add the value(s) to the total inside of the loop, and use the total after the end of the loop. specifically what values do you want to add up to make the grand total?
  16. your code is not testing if the upload worked before using the uploaded file. try this - if($_FILES['up']['error'] === 0){ // upload worked without any error $up=$_FILES['up']['name']; move_uploaded_file($_FILES['up']['tmp_name'],"upload"."/".$up); } else { // upload failed, do some debugging echo 'Upload failed.'; echo '<pre>'; print_r($_FILES); echo $_SERVER['CONTENT_LENGTH']; }
  17. @jazzman, i think your language translator is broken. the problem isn't the query. the OP can query for and retrieve the correct rows. the OP is making a QUIZ where the questions are displayed in a random order, without repeating a question.
  18. your post doesn't show what you mean by multiple strings/keys, so this is just a guess, but i suspect the answer involves arrays.
  19. http 500 responses from php scripts generally mean that your script had a fatal parse or fatal runtime error and didn't produce a complete response. in your case there's a fatal parse error because your the php statement on line 44/45 doesn't have a closing ; on it. please develop and debug php code with php's error_reporting set to E_ALL and display_errors set to ON so that php will help you. these settings must be in your php.ini to show parse errors in your main file. edit: once you fix that parse error, you have at least one more later in your code. TURN ON PHP'S ERROR_REPORTING/DISPLAY_ERRORS before you spend any more time trying to do this.
  20. what exactly don't you understand about the code that the comments don't explain?
  21. The form itself should be dynamically produced by looping over the $expected array. The $expected array may need to be expanded to hold unique information about each field, such as the field type.
  22. your first query grouped by the question. unless there are duplicate questions at any difficulty/topic, there's nothing to group. you second query is just numbering the questions in the query. the OP wants to randomize the display of the questions, so any numbering of the rows in the query would be out of order when displayed and has nothing to do with the stated problem.
  23. since you are storing the retrieved rows in an array, just use shuffle() to randomize the rows in that array, then loop over the shuffled/random array to output the questions. if ($ctr>0){ shuffle($arr); foreach($arr as $question){ echo $question; } } @jazzman, i don't know what you are reading in this thread, but the op has a number of questions for each difficulty/topic and wants to retrieve them and randomly output them. the problem is to output them without repeating any one question in a set.
  24. if you cannot find the correct one by examining the code, change each one to a different value - 'image1', 'image2' so that you can identify the correct one when it is output on the page. once you find the correct one and where in the code it is, you can find the filename variable (it will be fairly obvious since the filename variable is being used in the src=' ... ' attribute.)
  25. also, for mysqli_query(), the connection is the first parameter. The query is the second parameter. are you sure you are making a mysqli connection or is it a mysql connection?
×
×
  • 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.