Jump to content

ginerjm

Members
  • Posts

    6,906
  • Joined

  • Last visited

  • Days Won

    99

Everything posted by ginerjm

  1. You could include a counter in the first solution and simply check if the row you are about to output matches the counter, the counter being the next expected value. If it is not a match, output the blank/empty row you want and then do the normal output of the currently fetched row. Of course if there are possible multiple missing items, this counter itself would have to be in a loop, inside your fetch loop.
  2. LovePHP: mysqli requires the variable type to do the bind using the ? parm. Therefore the OP's code is correct as it is. Mac_gyver has solved the user problem - no data was being fetched. And Mac_gyver has my vote on his choice of PDO over mysqli!
  3. When dealing with associative arrays, ie indices that you generate rather than php, you should always quote them. Even if they are numbers.
  4. So - did you look at your db table to visually see what the value of id was?
  5. You should still alter it to handle case sensitivity!!! Read The Manual!
  6. Perhaps if you turn on error checking you might get something that could help? Also - in that error message code consider echoing the actual command to ensure it is correct. Also - the syntax I just checked shows a space after each switch. Plus you are including a last parm that seems to be repetitive.
  7. The two auto-incrementing keys are completely independent. Don't see what your concern is. Personally, I avoid AI keys like the plague.
  8. Feeling magnanimous this morning let me throw in my $.02 and give you a little outline of what the previous responders are suggesting. 1 - define all of your questions (as you said) by subject/chapter/subchapter/unique Q#/ etc. 2 - design a table to hole #1 - one record per question with all of its identifying criteria. During this design phase, be sure you have all of the possible attributes you may need for each question down the road. Maybe a date added to keep track of older questions (outdate perhaps?) or other such things. 3 - define a table to define your users. A name, an id, contact info and any other attributes you may need for your testees. You will have a record for each person who takes your quizzes. 4 - define a quiz table that will contain a user id from #3, a quiz datetime, the key info from #1 for each question that is part of this quiz and a result field to track the user's score on each question. Here you will have a record for each question for each quiz for each user. Make sense? When all is done you will be able to pick a user, show how many quizzes he/she has taken, when it was done and what their score was. You can also track what questions have been used the most or have been used for this user. To create a specific quiz you do a query of your questions to select what you want to test on. If this selection needs to be trimmed to eliminate questions already answered in other quizzes, you will have to either add that to your query or loop thru the query results and create that array you were thinking of with the question key info and using some logic to drop the repeat questions. from that array. If you also want to shorten the list by using some random number selector you can do this against that array as step 2 of this process. Once you have modified your list of questions into table #4. Now you can output this as a complete quiz and then update it with the answers/scores when the user finishes. This is an outline, taking into consideration what I kinda gleaned from your initial post. Good luck!
  9. if you turned error reporting you could see the error message
  10. I'm looking forward to your first sample of your own written code....
  11. If you are writing a function to pull one column at a time and plan on using it to repeatedly pull different columns from your database, that is truly a poor use of resources. Do not plan on pulling data one column at a time.
  12. I agree with Psycho's response and the idea of saving on the delete. Just add the token field to your one table, along with a time field for it to limit the amount of time the user has to respond to his/her activation/reset email.
  13. The php loop will happen on the server so the mouse over effect is moot at that point. The script will do its thing and return whatever to the client. At that point your html/css can hide the div if you want and a little JS can 'show' it upon mouseover. Two separate processes.
  14. Not sure what record you would be deleting in the database. A 'user' record, once established, should remain so that it doesn't have to be re-created with the user's help. Doing an account activation and a reset are similar as you suspect and no, the passwords would never be in clear text, if done correctly. Why do you think google is doing something like that? One doesn't submit a hashed password. The script receiving it does the hash before querying the db.
  15. ONe solution might be to isolate your login code to a separate login script that when successful saves a token for the session. This script (upon success) would re-direct you to some other script that does whatever function is needed. That script would only need to check for the existence of the token (or more stuff) to allow it to operate. In this way you remove any possible conflict (unresolved) between the two pirated code samples you have.
  16. Having used the php mail() function for awhile I have found that you really don't get any feedback from it. Even the response (true/false) isn't to be trusted. Many people here will tell you to seek out another mail program such as phpmailer, but I haven't attempted to install it as it seems rather complicated and not necessary for my uses. It may however be something that you want to explore if your need to ensure delivery is strong enough.
  17. Loop thru the results storing the values into an array that holds the values for each month. $ar['mth1']['val1'] += (amt); $ar['mth1']['val2'] += (amt); (rough code and un-tested) Then output your $ar values as you want them. You'll have to check for things like if either date falls in your desired months before saving its value. PS - couldn't you simplify your query by just looking for a start date and end date instead of all the functions?
  18. Does $column contain any spaces? One should really wrap associative indices in quotes to ensure there is no problem in determining the correct element of the array it is used on. $row["$column"] would be correct. BTW - you are doing a query that selects all rows but only returning the first row's value. Is that what you want?
  19. I would have expected you to actually show us the LINE IN QUESTION instead of talking about some function working "fine". Your line numbers (a PIA when you cut and paste your code!) - are they really the line numbers that the error message refers to or just some editor lines numbers that you pasted here? The line: $id = $row['id']; certainly doesn't have any problem so the " in the error message must be located somewhere else. Does the error message refer to another file perhaps?
  20. That code doesn't really show us anything. A session is not just for a form - it is everything that you specifically save as a session variable, regardless if it has anything to do with a form. Assuming that you have the session start at the top of THIS script, what does your following script have for code? And just what is that little snippet (poorly placed IMHO) doing for you? Is that the 'following' script? Why aren't you just using a header command from php?
  21. That is part of the beauty of retirement.
  22. I don't write for nor expect to appeal to international users. If you want to use my apps learn English. My apps are designed to work just like all of the code I have written for the last 40 years. Yes - the web environment is newest to me, but that doesn't mean that the same principles can't apply. Furthermore this learning process has taught me that you need to be careful about what you get from the user. Well - if I don't get the exact input that I am expecting then all is suspect. How can you dispel my logic on this point Jacques? If someone wants to somehow, someway send me input via ajax when I didn't design for that - it is their problem to deal with and not mine. Yes my browser and other experiences have been limited by what I have tried in a few different environments. Yes - I have experienced problems with my code for some older browsers but that has only been with the JS portions - and never with the PHP. Despite some people's research results, I have not had a problem with testing for a submit button value in IE8, nor in the later versions of that as well as Safari and Chrome.
  23. Kicken, Thanks for your reasonable response. It appears that I am not doing anything wrong in my current style, although I have yet to experience any 'missing button' phenomena. Should the future alter the current behavior of browsers, I am in a load of trouble!
  24. To answer your questions: 1 - never had to use ie8 2 - just tried it with the IE emulation mode set to 8 3 - my test properly recognized the submit buttons that I clicked on and acted accordingly. 4 - there is no reference to REQUEST_METHOD in my code. I will say that the js code sure popped up with a lot of errors! And not even my js code.
×
×
  • 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.