Jump to content

btherl

Staff Alumni
  • Posts

    3,893
  • Joined

  • Last visited

Everything posted by btherl

  1. "-0" will cast a value to an integer. In this case I don't see any need to do that..
  2. does an onunload="alert('the page is closing, abandon ship!')" work?
  3. There's many reasons that it could be timing out .. as a first start, I would add a depth limit for the recursion. So it would look like this: function getAllRef2($user_id, $depth){ if ($depth == 10) { die("Recursion reached level 10. Is there a loop somewhere?"); } global $db,$user; $sql=$db->Execute("SELECT user_id FROM user WHERE sponsor='$user_id' "); $my_dl=$sql->RecordCount(); while($fet=$sql->FetchRow()){ $id=$fet['user_id']; $dl=$this->getAllRef($id); $dl2=$this->getAllRef2($id, $depth + 1); //$my_dl= $dl + $dl2; $my_dl+=$dl; } // echo "kl: $dl2"; return $my_dl ; } Then you call the function as getAllRef2($id, 0); Even after you find the bug you should keep this code, as it will prevent similar problems in the future due to corruption of the database data. This might not find the problem, but it will at least eliminate one potential source.
  4. Oh yes .. you're right. There's a way to do it though: http://www.webmasterworld.com/forum21/1268.htm I have seen this implemented by a domain parking company. You can see a sample of how it works at http://www.checkorderexpress.com (you must look in the frames, the main page is just a frame set). The variable that controls it is doPop, and it is set to 0 by all internal links. Then the onunload action checks that variable each time. If it wasn't set to 0 (indicating internal link), then the popup is popped. This may be a problem if someone has multiple windows of your site open and closes one of them. I don't know how to deal with that situation.
  5. Hmm.. it's possible that mysql is misinterpreting the way that you combined everything. It's hard to guess without seeing the full query and where it should be combined, but you may have to repeat the WHERE condition for EVERY select .. that will give you an ugly query but mysql won't mind. While you can factor out the "where", performance may suffer unless the query optimizer knows it can apply it to each of the unioned subqueries. Can you post the attempt you made at combining?
  6. That looks fine then.. how did you find that it was printing \ and n instead of \n? Oh, and try neon's suggestion \r\n is the windows end-of-line
  7. This may help .. popup blockers will probably stop this though.
  8. I don't think there's a security problem there. Just make sure you sanitize any user provided data that goes into database queries. There's no need to close the connection early for security (though it's often good for performance reasons).
  9. I think your code assumes that the wday of Sunday will be 7 .. it is actually 0. Given the format of your calendar, I would manually change any wday of 0 to 7 after getdate(), as that will make things much easier.
  10. It's not a simple question. But in general, you should index at least one column from the "WHERE" conditions of your queries. For example, if you are always searching "where topic_id = ...", then you will very likely get a more efficient system by creating an index on topic_id. In nearly all cases, you should index the stuff SEARCHED. But in some rare cases you can in fact benefit from indexing the stuff DRAWN. I would not worry about that yet though. To find if you need an index or not, try timing your queries. If the query is looking slow, take a look at the "where" clause and consider what index would narrow down the possible values enough to make the query fast.
  11. Based on general sql knowledge rather than knowledge of this specific application, I would say yes it is to do with the null option. Let's say you defined thumbPath to be "not null", and also didn't give it a default value. Then you entered data into that tables but didn't say what thumbPath should be. Then what is the database supposed to do? If the column was nullable then it would put null in there to mean "unknown" or "no value". Or if you set a default value, then it could use the default. But if you said it can't use null and didn't give it a default, then it just gives up and says "I can't do that"
  12. Try echoing "\n" instead of '\n'. Double quotes are necessary for those special characters.
  13. The code you posted uses the variables $group_id, $lookup and $db_prefix. If these variables are not set, or have different values, then the code will behave differently. So this could be why the same code acts differently when used in different places. Here's how you would do the printing check: if (!isset($group_id)) { print "group_id not set. Entering redirect check with lookup = $lookup, db_prefix = $db_prefix";exit(0); if (!isset($lookup) || !isNum($lookup)) fallback("index.php"); $result = dbquery("SELECT * FROM ".$db_prefix."users WHERE user_id='$lookup'"); if (dbrows($result)) { $data = dbarray($result); } else { redirect("index.php"); } What that will do is tell you what $lookup and $db_prefix are set to when that code is entered. After observing the values, you can delete that line and continue debugging. I use this method hundreds of times daily while developing code. The reason for the exit(0) is that a 302 redirect will prevent you from seeing the output of the print statement (that is, if the script is doing a 302 redirect. If it isn't, then you don't need to exit)
  14. I don't understand your last sentence there. Perhaps your code is not setting $lookup, but the place where you cut and paste from IS setting $lookup? You can try printout out the value and then terminating the script with exit(). The reason for terminating is so you don't get redirected and lose your output.
  15. Perhaps it times out? A timeout could occur either on the server or on your browser. Or there could be underlying network instability that means that long-running transfers like that tend to be broken part-way through.
  16. You might want to use a union here.. something like: SELECT a.cat1 FROM tablea a JOIN tableb b ON (b.id = a.cat1) UNION ALL SELECT a.cat2 FROM tablea a JOIN tableb b ON (b.id = a.cat2) UNION ALL SELECT a.cat3 FROM tablea a JOIN tableb b ON (b.id = a.cat3) JOIN makes more sense to me here rather than LEFT JOIN. I'm not 100% sure of the syntax there as I am not a mysql user.
  17. It sounds like you've already got code to create the member list, so I'll just give the specific stuff. $members_sql = '1|87|38|5|25'; # Original list from SQL $members_arr = explode('|', $members_sql); # The exploded member list $members_arr_new = array_diff($members_arr, array('38')); # Remove member 38 $members_sql_new = implode('|', $members_arr_new); # Ready to go back into SQL There are many other ways to remove an element from an array, but I think array_diff() is the simplest.
  18. I have an answer and a question.. The answer is that ";" can sometimes be used instead of "&" The question is: TCP is at a lower level to HTTP, and deal with connections between hosts. HTTP is the level at which "&" is used. I would not expect a TCP object to deal with "&", which is an HTTP thing. Are you using the right object?
  19. If you're asking "How would I do this in SQL", the answer is "With great difficulty". That data structure is just not suited to SQL manipulation. But you can easily read the row into PHP, explode it into an array, remove the offending member id, implode it and store it again.
  20. What's with the call to getAllRef() in getAllRef2()? Something looks suspicious there. getAllRef2($user_id) returns the count of all users in $user_id's downline, is that right? And it does it by recursing into itself. Does that function work correctly? And selectUs($user_id) seems to do the same as getAllRef2().. is that correct?
  21. btherl

    why...

    Are you sure you're not just keeping it open for comic relief?
  22. This line echo $row[gName]"<tr> should be echo $row['gName'] . "<tr> Edit: Oops, yes you should have quotes around the gName too
  23. You can use readfile() instead of include() (this is recommended in the php manual)
  24. Ok, that means that your code is being executed but is not doing what it should be doing. Can you post your query as well? Oh, a good thing to do would be to var_dump($song) after the call to checkrow(). That will let you know if the changes are really being applied to $song
  25. btherl

    why...

    phpsux, I assume you must not be aware of Intercal? It is clearly superior to both the PHP and HTML technologies. Facebook was written in Intercal, as was Windows ME.
×
×
  • 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.