Jump to content

Pandemikk

Members
  • Posts

    144
  • Joined

  • Last visited

Everything posted by Pandemikk

  1. You really need to pay attention to what you're doing. You have an unnecessary parenthesis which is terminating your if statement prematurely. IF(Performance.startDateTime >= Now(), 'True', 'False')
  2. The problem lies here: IF(([Performance.startDateTime]>=Now() - INTERVAL 1 DAY),"True","False") It's converting > and " to html entities which makes me think there's a problem with how you're having that condition used in the actual query. I'm confused about some of the stuff you're using in the query as well. "[Performance.startDateTime]>=Now() - INTERVAL 1 DAY". It looks like you're trying to use .asp in a query? That's not going to work out. IF(([Performance.startDateTime]>=Now() - INTERVAL 1 DAY),"True","False")
  3. Well there could be many reasons. You have lots of things wrong with your code. Does $_POST['p'] actually have any data in it? Can you var_dump($questions) right before you do the for loop and paste what you get here?
  4. Both of them? Well $score is 0 because your for loop isn't getting looped because count($questions) is 0. And I think I see one problem, your code shows "if(result)". It should be if ($result).
  5. That means either $score or count($questions) is evaluating to 0 (perhaps even both). To debug which one, please var_dump both of those and exit(); right before line 13.
  6. I'd suggest building a working local copy of what you intend to do first. Once done, see to try and patent as much as you can (not everything can be patented) then hope for the best. If your idea is any good it'll be extremely popular before any rich fuck who wants to steal your ideas can get a decent replica and by that time your customer base will have no reason to switch. The key is to keep updating and to keep your customers happy.
  7. I didn't mean to imply that it was too advanced for me to bother with. Simply stating that I would love to learn how to do it that way but I just can't understand it, so if you had any pointers or could lead me in the right direction that'd be much appreciated. And the reason I don't want to run it x amount of times is for performance reasons. The page I'm running it on already has lots of queries and PHP processing so anything I can do to lessen the load is ideal. Plus it's good for me to start learning more advanced queries. So please don't take it as "I don't like it". It'd be much easier to do so doing it that way, but coding isn't always about doing what's easiest - though at times (perhaps this one included) that may be best.
  8. Well if you wanted a specific number for them that'd be much easier. What your original post asked for was to put random team_ids for existing team_ids into the database, which is what my code was for. If you want to assign specific keys specific values to be inserted all you need to do is this: <?php $teams[0] = 4; $teams[1] = 2; $teams[2] = 5; // etc ?> Or if you did indeed want to make them random you must not have added the 5th array as btherl stated.
  9. I'm not sure if you're done here or what but I have something to add: It is better to see if a result exists doing this: <?php if (mysql_query($query)) { // Result exists [username taken] } ?> It's shorter. Just a personal preference though.
  10. That's a for loop. Not a foreach loop. Personally, I'd recommend a foreach loop. And btw, don't use count() inside a for loop. Assign count to a variable and use that instead. The problem with your code is you're shuffling the array but updating each team_id with the current array value where its team_id is the current array value. Basically, all shuffle has done is determine what order you're updating when you want it to be randomly updated. What you need is to update team_id with the the old team_id's value. <?php $teams = array( 0 => 1, 1 => 2, 2 => 3, 3 => 4 ); // preserve team_ids $teamids = array_values($teams); // randomize shuffle($teams); // old team_ids are the keys and randomized team_ids are the values $teams = array_combine($teamids, $teams); foreach ($teams AS $key => $val) { $db->query("UPDATE ancl_teammeta SET team_id = $val WHERE tmeta_id = $key"); } ?> There is one problem here. It is possible for the key and value to be the same thus not updating that specific team_id at all. I'm not sure if this will be a problem or not. Btw, shuffle assigns new keys to the elements. It's a bit of a pain.
  11. No. Listen to what I've said. Change your form method to post. It will fix the error and it will make your coding more correct. It will also make it slightly safer.
  12. GET should never be used except for retrieving data. Your form is submitting data to be processed by the server and updates the existing resource. This is exactly what POST is for. A form that submits information to the server should almost always be post.
  13. Okay, first of all that's a WEB HOST issue. Not a PHP one. Ask your WEB HOST to white list it for (just like the link says you should). Secondly, you can avoid this whole problem if you use the proper request method. If a user is submitting data to be processed by the server the form method should be POST (method="post"). Then you can access this data the same way you accessed it before but with $_POST instead of $_GET. Now you've solved your problem and are using proper http protocol.
  14. Maybe he no know. OP, maybe you should try telling us your error.
  15. Arrays with keys but no values for those keys will not be considered "empty". Depending on what you're trying to do, you could loop through each array and check if the value exists and, if not, trigger an error then. But I think your issue lies with more than that. See what the above poster said^.
  16. I'm sorry but that's a bit advanced for me. I'm having trouble finding out exactly how to do it.
  17. You would test the array keys? I'm not sure what you're asking or what you're trying to accomplish. Are you suppose to get a specific number for that array? if (count($carton) < 2)) { // Error }
  18. That'd be easy enough. But, if possible, I wanted to do this in one query (or else I'd simply make my life easier and make three queries).
  19. How is that going to help? Last I checked forward slashes aren't HTML entities.
  20. I'm a bit confused. You have a form for user submission, correct? Then why is the meth GET? It should be POST. In your PHP code I don't see you accessing "background" from the GET superglobal (which should be accessed from the POST superglobal) so I'm not sure how you're sanitizing it. Nor am I sure where the code is "failing" since you haven't told me how like I asked.
  21. What do you mean it fails? Saving it into the database fails? You get a PHP error? Please shorten the code you posted to just the complete form and the part of the PHP that assigns the forum values.
  22. Forgive me for the title, it's a bit lacking in descriptiveness. What I currently have: $results = $this->registry->db->query_read(" SELECT title, threadid, forumid, dateline FROM " . TABLE_PREFIX . "thread WHERE postuserid = " . intval($this->profile->userinfo['userid']) . " AND sticky != 1 AND forumid IN (13, 19, 39) ORDER BY dateline DESC LIMIT 0,50 "); This is fine for returning of the latest results to be readied for pagination by PHP. But I want to be able to have, say, 30 results for EACH forum ID (13, 19, 39, etc) without having to do 3 separate queries. Is this possible?
  23. Use isset($_SESSION[$whatever]); As far as md5 goes, when someone registers to your site you will need to store the md5 hash of their password into the database. Have you been doing that? Are the passwords in the database md5 hashes?
×
×
  • 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.