Jump to content

btherl

Staff Alumni
  • Posts

    3,893
  • Joined

  • Last visited

Everything posted by btherl

  1. This looks like a DST issue. DST typically starts on 25 March. But your code looks ok to me. mktime() is supposed to handle DST changes. Maybe try another way of calculating?
  2. Ok, I read the article. I'm very confused about what you are trying to do though. 1. Why are you using UNION with Toxi's queries? They already handle OR and AND. 2. Do you want life AND death or life OR death? Simple IN works for OR. IN combined with HAVING works for AND. What is it that you need to do that cannot be expressed using Toxi's queries? Regardless of that, I don't understand why the union would return duplicate rows in the result. Are the rows that are duplicated exact duplicates?
  3. You won't get sensible results if you mix c_weight and MAX(c_weight) in one query. Mysql will give you a TOTALLY RANDOM value for c_weight, chosen from the possible rows. It's best if you do one query to find maximum weights, and another query to find individual weights. The individual weight query should not use GROUP BY. As for your data structures, you may find it easier to use this: $catch_data = array(); while ($list = mysql_fetch_array($dbresult)) { $catch_data[$cnt] = $list; $cnt = $cnt +1; } print "r_nick_name[1] = " . $catch_data[1]['r_nick_name']; It'll save a lot of typing Of course your sorting will have to be done differently. Feel free to ask about that.
  4. dustinnoe, did you try the query toplay suggested? The only thing I see it doesn't do is check your "HAVING" condition. That's fine if you don't mind applying the condition to both queries, in which case you can just add it to toplay's query.
  5. What is mailSender() ? Can you provide the source for that function?
  6. The short answer is no.. you must tell the browser where to find the image. And if the browser knows where to find the image, then the user does too. The long answer is that there are many methods of restricting access. You could use javascript to obscure the url to the image. But that is easily defeated by someone recording the requests made by the browser. You could also check the referrer, to ensure that the user is viewing the image from your site. That will prevent re-use of your images on other sites (while still hosted on yours). It all depends on why you want to hide the image.
  7. The first thing i notice is that you are assigning $numofrows_sub_items each time around the while loop, but you only print them after the while loop. This will result in you only seeing results for the last sub-category returned by your query. It's the inner most while loop I am talking about. Your code is rather confusing without indentation Please indent it!
  8. SELECT * FROM user_data JOIN user_weapons ON (user_data.user_id = user_weapons.user_id) JOIN game_weapons ON (user_weapons.weapon_id = game_weapons.weapon_id) WHERE user_id = $user_id That's the basic structure for a join.
  9. The first thing that comes to mind is to swap the order values when you press + or -. That guarantees the behaviour you want. Deletion is also simple. But insertion may cause problems, as you may not have enough space between two order values. It seems messy. Perhaps you could use floating point numbers, and insert by creating a number between the next greater and next lower values. Or you can just move all subsequent values along when you insert. That's fine as long as you don't have too many items to move.
  10. Replace $sql = "DELETE FROM $tbl_name WHERE id='$del_id'"; $result = mysql_query($sql); with $sql = "DELETE FROM $tbl_name WHERE id='$del_id'"; echo "About to execute $sql<br>"; $result = mysql_query($sql) or die("Query failed: $sql\n" . mysql_error()); and take a look at what it prints out. If it's not what you expect, work backwards through the script printing out other values, such as $checkbox[$i], until you find the problm.
  11. I don't understand your question. Can you describe what you post to the form and what you see? If you get an error, please show the exact error.
  12. Try a script that does var_dump($_POST), and you'll see what happens when enter is pressed. Because you never clicked any submit button, the browser doesn't have to set the submit button to "successful" and add it to the post data. You can also submit a form without a submit button using javascript.
  13. I tried here with IE 6, and didn't see any difference. If I clicked the button, I would see ASCII, regardless of whether I used the left or right shift key. If I hit enter instead of clicking the button, I would see nothing.
  14. That's the end of the entire script? Is that script included or required from any other script? Try altering doquery() so it prints out every single query its asked to run. As long as all your queries go through doquery(), it should be impossible for anything to slip past without being printed out.
  15. Don't worry about that.. I was off in la-la land. Just read the second part of what I wrote Because the exit() fixed things, that proves that the script runs another query later which updates the database again. So now you need to find where that happens. It also proves that the script isn't being run twice, so there's no need to check for that.
  16. Edit: No need to check if it's being run twice.. it isn't.. i'm not thinking today The other possibility is that some code later in your script does another query. You may have to print output for every single query you run to find which one it is. If doquery() is your own function, then just edit that and have it print out every single query passed into it. It's a lot of work, but you will find the problem And once you find it, you'll know how to stop it happening again.
  17. The problem before was that you were sticking strings together with no spaces, so your queries would look like this: SELECT *FROM lab5WHERE address = '$address' As for what your problem is now.. try printing out the query you are about to run, to make sure it looks like you expect it to.
  18. Here's an idea to narrow down the cause of the bug. Immediately after the query which you know 100% does the correct update to the database, add exit(0), so the script terminates immediately. See if the database looks ok after that. Then try it without the exit() call. If the database has the correct value after the exit(), then you know that there is code running AFTER that point which is doing the second update. If the database still has the wrong value, then you know that the script must be being called a second time somehow.
  19. I noticed something strange in your code. You start by selecting all entries from the blogs table, within a certain range. Then for each row, you select exactly the same data again with your second query. You could simple take page_views from your first query. As for your last query, it looks perfectly fine to me. Maybe you can post your database structure, and also post a sample of what you want the query to return?
  20. No, it's not mysql. Software as mature as mysql doesn't make mistakes, especially not ones like that. The only explanation is that your script is running ANOTHER query which is updating the database again. There are many ways that could happen.. it could be triggered by a browser or cache making two requests for whatever reason. It could be caused by accidentally including a file twice. Or it could be caused by having old code lying around. Another possibility is that some code you aren't expecting to run IS running, causing the second update. If possible, log all queries to a file. Then you can see what's really going on.
  21. Looks fine to me. What does it display, and what do you want it to display instead of what it does?
  22. Did you print out the mysql statement itself? $sql = "UPDATE {{table}} SET $potions gold='$newgold' WHERE id='$userid' LIMIT 1"; print "About to run $sql<br>"; $updatequery = doquery($sql, "users");
  23. What do you want the output to look like?
  24. Can you post your script? And your form as well, if it is in a different file to your script.
  25. You can do $a = array(1,2,3,4); print "<pre>" . print_r($a,true) . "</pre>"; but not with var_dump() which can't return its output. So in the case where you want to display several strings including the output of var_dump() or some similar function which displays output, and you want it all in a single statement, THEN you need to use echo and not print
×
×
  • 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.