Jump to content

btherl

Staff Alumni
  • Posts

    3,893
  • Joined

  • Last visited

Everything posted by btherl

  1. It'll be there somewhere A simple method to find where is to print $target_id out at various stages throughout the script. Somewhere it will change from 2 to 3. Or it may even be 3 from the very start.
  2. Ok, here's some steps which will fix your problem. First, echo out the query before running it, like this: $sql = "SELECT * FROM `fusion_wars` WHERE `a_id`='".$user_id."' AND `d_id`=".$target_id." LIMIT 0 , 1"; print "About to run $sql<br>"; $result_war = dbquery($sql); Then, after you've fetched the data, print it out: $data = dbarray($result_war); print "<pre>"; var_dump($data); print "</pre>"; Do they match up?
  3. And what is this doing just before your query? $target_id = 3;
  4. It appears the data from the database is correct. It is for target_id 3. Why do you think that it is incorrect? Edit: If you look in the var_dump() output, you will see that d_id is set to 3, and the other data is all for the matching row from the db.
  5. Try this: ob_start(); while ($result = mysql_fetch_array($query)){ include("post.inc"); } $string = ob_get_flush(); ob_start() will start buffering output, and ob_get_flush() will grab the buffered output and put it in a variable.
  6. Can you add the following inside the if statement for me? var_dump($data); And then show us the output.
  7. Does it return the rows with the data you are expecting? You can always track down a bug by tracking the data backwards until you find the point at which it changes from being correct to incorrect. That point is exactly where your bug is. Right now you know that $data['a_turns'] is incorrect. So go back through your code printing out values until you find where it becomes correct. Then you have the exact location of your bug
  8. I would try running that query manually. Or at least printing out the query before executing it. In this type of situation, it's usually the wrong query, or the data in the database is not what you thought it was. The other common situation is using the wrong result variable, but that looks ok for your script. I would check that you are actually getting rows back though.. have an "if (dbrows($result_war) == 0) { print "No rows returned??<br>"; }"
  9. Are you able to encode the variable name as well as its value? For example $varname = 'my.foo'; $varval = 'hello'; $encoded = urlencode("$varname=$varval"); $url = "index.php?var=$encoded";
  10. Have you decided yet how you will store the data?
  11. How about having the forum send you an email, then setting your email client to make the sound?
  12. How about this structure? quiz_id question answer 1 1 3 1 2 4 1 3 1 It'll be easier to work with than having one column for each question. In general, using columns for 20 things which are only distinguished by number is a bad idea. It's better to put them in rows, and put the distinguishing number in a single column.
  13. You can try this (as long as the server is not set for safe mode): http://sg.php.net/manual/en/function.set-time-limit.php
  14. Can you post your current code?
  15. If you are running on unix, you can do $last_line = exec("/usr/bin/last $file"); Don't do that if $file was passed in as an argument to the script, as that would be a major security risk.
  16. Actually, null is "not set". It's an empty string that is set. The full table is here: http://sg.php.net/manual/en/types.comparisons.php
  17. mkybell, what do you get from the subquery from my above suggestion? SELECT itemID FROM reviews WHERE reviewerID = $reviewer Does this really fetch all reviews by the current reviewer? If it does, then the query I suggested will work.
  18. I can offer a push in the right direction. Start by removing all the @ from your functions. All @ does is hide errors from you. Instead, write them like this: $connect = mysql_connect($hostName, $userName, $password) or die("Couldn't connect to database"); Do the same for mysql_select_db() and for EVERY call to mysql_query(). For mysql_query(), do it like this $query = "SELECT * FROM pilots"; $result = mysql_query($query) or die("Error in $query\n" . mysql_error()); But do NOT use "or die" with mysql_result() or mysql_num_rows(). Leave those as they are.
  19. You can use auto_increment / serial, as described here: http://dev.mysql.com/doc/refman/5.0/en/numeric-type-overview.html
  20. Databases can't sort across columns. Though you can kludge it. The easiest way to do this is to read the data into php and sort it there. If you REALLY want to do it in mysql, you can do something like SELECT Constituency, 'Electorate' as party, Electorate FROM votes UNION ALL SELECT Constituency, 'Gold Party' as party, `Gold Party` FROM votes ... and so on for each column. Then you can just sort by votes. Essentially you need to convert the columns into rows before you can do any kind of sorting in sql.
  21. Nice use of highlighting Hmm.. tough situation. How about SELECT * FROM items WHERE itemID NOT IN (SELECT itemID FROM reviews WHERE reviewerID = $reviewer) The subquery gets ids for all items reviewed by that reviewer. Then the outer query gets all items NOT in the list of items reviewed by that reviewer.
  22. Also, have you printed out all of your mysql queries to ensure that they are what you expect them to be?
  23. You could use strace to see what files php opens. Here on my debian system it opens /etc/localtime, which links to /usr/share/zoneinfo/Australia/Melbourne (actually I am in singapore but my system runs on Melbourne time)
  24. Did you add it to the subquery (inside the brackets) or to the outer query (after the final closing bracket) ?
×
×
  • 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.