Jump to content

btherl

Staff Alumni
  • Posts

    3,893
  • Joined

  • Last visited

Everything posted by btherl

  1. Try this: <textarea ><?php echo "Testing \r\n testing."; ?> </textarea>
  2. Textarea should understand \n, or perhaps \r\n together. Have you checked the source of your page to ensure that the new lines are shown in the source?
  3. Your script doesn't have to walk through the js, but you do, so you know which requests to do.. I expect they are the same requests every time. I've done something similar before. It's a huge lot of work, but it is possible. I even had to parse certain tokens out of some urls to get it working properly. But my script never understood the js itself. It was me interpreting the js and telling it to blindly send off some requests that the js would have told it to do. FOLLOWLOCATION doesn't work because the redirect is done in javascript, not at the HTTP level.
  4. BAD ADVICE For this application, SQL is vastly superior to flat files, so the developer got that right. As for what's slowing it down, it's hard to say without profiling. Have you tried apd (a php profiler)? It can be a little messy to setup, but it provides valuable data. Another option is to make your own code to profile various parts of the processing, and find where the time is going. The reason profiling is the place to start is so you don't waste time optimizing things that don't actually take much time. Once you know what is slow, then it's time to look at moving those parts into mysql.
  5. I suspect it's using javascript to do the redirect. When I view the site in firefox a box comes up asking me to wait, then I am sent to that second URL. The second url seems to know what property I want, so that data is probably stored server side. And the second url DOES appear to have prices in its source.
  6. What does your browser show in the address bar when you do View Source ?
  7. Correct regexp is: preg_grep('/(?:jpg)|(?:gif)/', $content) If you want to match only at the end of each string, use: preg_grep('/(?:jpg)|(?:gif)$/', $content) That will not match "gif.html", but will match "html.gif". That makes sense if your content is actual filenames, but not if it's html.
  8. I'm not seeing what you see. They look much the same to me. File size is different only by a few hundred bytes. Are you using the same user agent for curl as your browser is using?
  9. That site uses LOADS of javscript. It's not going to be as simple as fetching the page, you will also need to go through the javascript and find where the property values are actually being fetched.
  10. $update4=mysql_query("UPDATE admin SET timediff = timediff( UNIX_TIMESTAMP( timein ), UNIX_TIMESTAMP( timeout ) ) WHERE username='$username' and timediff IS NULL AND ( timein < timeout OR timein = timeout ) )") or die(mysql_error()); It is very important to have the "or die" after each of your mysql queries. If it doesn't work, that well tell you why it doesn't work.
  11. You can pass the url in the location header, like this: header("Location: http://blah.com/login.html?url=" . urlencode($my_url)); You will need to set $my_url appropriately from the $_SERVER variables. Then inside login.html: $referrer_url = urldecode($_GET['url']); Or you could just use sessions. $_SESSION['url'] = $my_url;
  12. Why do you need to use pg_num_rows() on the first query when you have already fetched the total count in the second query? Is it pg_num_rows() that you are having trouble with?
  13. Ok, I understand the problem now. But I don't see why it is difficult. If an href does not have a hostname, then you need to add the hostname. If it does have a hostname, then you don't need to add it. With the subdomains, you can extract the hostname from the link and check if it is subdomain. What is the approach you are using now, and why is this difficult?
  14. What is the underlying problem that gives rise to this solution? There may be a better solution, such as passing along a token unique to each page view, and not allowing re-use of old tokens.
  15. Can you give some more detail? I don't understand your question.
  16. Ok, some of that is easy: $got_alpha = preg_match('|[A-Za-z]|', $password); $got_num = preg_match('|[0-9]|', $password); But as for the symbols.. there are four groups of symbols in the ascii table $got_symbol = preg_match('|[ -/:-@[-`{-~]|', $password); That oughta work. After that you just need to check if (($got_alpha && $got_num) || ($got_alpha && $got_symbol) || $got_num && $got_symbol))
  17. The cleanest way is with parse_url() $action = "http://scuba.about.com/cs/snorkelgear/bb/snorkelequip.htm"; $action_parts = parse_url($action); var_dump($action_parts); var_dump() will show you the contents of $action_parts, so you can see what's inside and choose which parts to use. You would remove it in your final code.
  18. Are you checking for "at least one alpha" and "at least one number" ? So these would be valid: Nt4% NN99 55%%aa qwer!@#$ But these would be invalid abcd 1234 !@#$ because they only contain one class of characters
  19. Congratulations I would recommend against the ${$var} syntax if possible. It's much cleaner to use associative arrays all the way through.
  20. Google says this is a mysql issue. Are you using a webhost (which one?) or your own home installation?
  21. But $field IS a variable.. Can you give an example with the values substituted? Eg $a1 = $row_attend['a1'];
  22. What is the underlying problem you are trying to solve? As for the tap-dancing, it sounds like you want to make an ajax style call back to php.
  23. I really don't get what you're trying to do. And what is the error you got? Did you mean to do this: ${$field} = $row_attend[$field];
  24. The other option is ORDER BY CAST(foo AS UNSIGNED) What happens when you add 0 to foo is that mysql is forced to convert foo into an integer. After that, it is sorted as an integer. The same happens when you explicitly cast foo to an integer using CAST(). "Cast" means "Change from one type to another". The original problem is that your numbers were being sorted as strings, which is why it looked at the first character first, then second, and so on.
  25. Here's some sprintf examples. Basically, sprintf replaces things like %s and %d with variables. $name = 'Bob'; $num_widgets = 5; $message = sprintf('%s has %d widgets', $name, $num_widgets); The replacements are done in the same order as they are written. %s means "string", and %d means "integer". Play around with that a while and get familiar with it, and you will understand the code you posted better!
×
×
  • 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.