Jump to content

ManiacDan

Staff Alumni
  • Posts

    2,604
  • Joined

  • Last visited

  • Days Won

    10

Everything posted by ManiacDan

  1. Then this is too much for you, and you have to pay someone to do it. I even told you that you click on something or enter something to get these results. Did you look for that?
  2. What were you trying to show us? I'm not reading 400 lines of uncommented code without a single word of English from you.
  3. Nowhere, I've said that three times now. You do not put that anywhere. This problem is not solved by you sticking an entire fully-formed query into an existing script. You have to find an existing query and edit it. function get_search_results() accepts a variable: $search Now, continue debugging. Where does $search come from? Searching you code for $search produces: if (isset($_GET['search'])) $search = $_GET['search']; $_GET is an array of user input. Whichever page you are at before this page is the page that's generating the query. You click on something to get here. That something is what you need to edit. If you typed a query into a box to get to this page, that's the query we've been talking about for 4 pages now.
  4. PHP5+ is optimized for interpolated strings, believe it or not. Check this speed test: <?php $short = array("apple", "banana", "coconut"); $long = array("Alice", "Bob", "Claudia", "Dan", "Edgar", "Frank", "George", "Harry", "Ignacious", "Jerry", "Kate", "Larry"); echo "Interpolation...\n"; $start = microtime(true); for ( $p = 0; $p < 1000000; $p++ ) { $a = "My three favorite foods are: {$short[0]}, {$short[1]}, and {$short[2]}"; } echo "\tShort: " . number_format(microtime(true)-$start,2) . " seconds.\n"; $start = microtime(true); for ( $p = 0; $p < 1000000; $p++ ) { $a = "There's a lot of people here, like {$long[0]}, {$long[1]}, {$long[2]}, {$long[3]}, {$long[4]}, {$long[5]}, {$long[6]}, {$long[7]}, {$long[8]}, {$long[9]}, {$long[10]}, and {$long[11]}"; } echo "\tLong: " . number_format(microtime(true)-$start,2) . " seconds.\n"; echo "\nConcatenation...\n"; $start = microtime(true); for ( $p = 0; $p < 1000000; $p++ ) { $a = 'My three favorite foods are: ' . $short[0] . ', ' . $short[1] . ', and ' . $short[2]; } echo "\tShort: " . number_format(microtime(true)-$start,2) . " seconds.\n"; $start = microtime(true); for ( $p = 0; $p < 1000000; $p++ ) { $a = 'There\'s a lot of people here, like ' . $long[0] . ', ' . $long[1] . ', ' . $long[2] . ', ' . $long[3] . ', ' . $long[4] . ', ' . $long[5] . ', ' . $long[6] . ', ' . $long[7] . ', ' . $long[8] . ', ' . $long[9] . ', ' . $long[10] . ', and ' . $long[11]; } echo "\tLong: " . number_format(microtime(true)-$start,2) . " seconds.\n"; echo "\nBare strings, no variables...\n"; $start = microtime(true); for ( $p = 0; $p < 1000000; $p++ ) { $a = 'My three favorite foods are: apples, bananas, and coconuts'; } echo "\tSingle quoted string: " . number_format(microtime(true)-$start,2) . " seconds.\n"; $start = microtime(true); for ( $p = 0; $p < 1000000; $p++ ) { $a = "There's a lot of people here, like Alice, Bob, Claudia, Dan, Edgar, Frank, George, Harry, Ignacious, Jerry, Kate, and Larry"; } echo "\tDouble quoted string: " . number_format(microtime(true)-$start,2) . " seconds.\n"; echo "\nDone!\n"; Outputs: [maniacdan@maniacdan ~]$ php bar.php Interpolation... Short: 0.45 seconds. Long: 1.59 seconds. Concatenation... Short: 0.53 seconds. Long: 2.38 seconds. Bare strings, no variables... Single quoted string: 0.14 seconds. Double quoted string: 0.15 seconds. Done! Concatenation is slower, especially the more variables you're concatenating. Interpolation is faster. It doesn't make any sense, but there it is. For bare strings without ANY variables, double-quotes are only very very slightly slower. Nothing compared to the benefit of using them when there's variables involved. (Test run on 5.3.
  5. You are NOT supposed to make a whole separate query and just stick it somewhere. You have to find the relevant query and edit it to have an ORDER BY clause. What is the filename of the second file? Where does it fit into the first file? Edit: get_search_results() is the function that generated that variable. Which, again, is not in the code you provided. This is how debugging works. You wanted to sort the results. Go back until you find where the results come from.
  6. The facebook button is an iframe, and cannot be changed by you. Facebook changes the like button every few weeks, sometimes a few times a week. I've seen the box change size, shape, and color multiple times throughout the day. You absolutely cannot let your layout depend on it.
  7. This line: extract($search_results); That line tells me that somewhere above this code (or in a file that includes this code) there is a variable called $search_results. That variable is the result of (you guessed it), the search. The search is the query. That query is what you need to change. You've been in the wrong file this whole time. Also, extract() is bad practice and lazy. Why? Because you end up not knowing what variables and files you're supposed to be looking at, because you can't tell what the variable names are supposed to be. Exactly as what happened here.
  8. You're making this code worse instead of better. Un-do everything you've done and start from the beginning. somewhere in your code that you have not yet shown us, there is a query that generates $total_results. That query, and only that query, needs to have and ORDER BY clause.
  9. The 3 line thing I gave you checks exactly what was asked for: The "load time" of an external script. It measures the amount of time it takes for the script to execute and finish giving output. The pingdom test does that, and then parses the output to see if it's HTML. If it is, it fetches images, javascript, and CSS as well, probably in parallel.
  10. the pingdom test also fetches external javascript and images. If you want to find the complete load time of a site and all its assets, it will be a significantly longer script. Many sites these days also draw a portion of their interface in javascript, which is even more difficult to time properly.
  11. I think this was the source of the whole disagreement. Excel never did that for me with a 1,2,3,4,5 file, no quotes. OOo pulls up a little "this looks like a plaintext spreadsheet, what's the delimiter, it looks like a comma" dialog.
  12. Your question, from what I can figure out, is that you want your query sorted using standard natural sort. Your answer, as you've already been given, is an "ORDER BY" clause in your query. You could also use usort or array_multisort in PHP, but the answer is "order your query." Since you have not clarified anything at all, including what database you're using, that's all the help I can give. Also, reading the links on how to post a good question will help you post questions that don't turn into 2-page arguments about what you mean.
  13. An external page? $start = microtime(true); file_get_contents('http://www.yourURL.com/page.html'); echo "Page loaded in: " . number_format(microtime(true)-$start,2) . " seconds.<br />";
  14. Please format your code better, control structures all on one line is hard to read or understand. if ($this->sourceURL=="http://blah.com/blah/misc.php"){$this->endURL="http://blah.com/blah/misc2.php?r=" . $this->Gate_sourceURL;} You forgot the parens after Gate_sourceURL. Since you didn't see the error, that means you're running without error-reporting turned on, which is bad. You also have a terrible naming convention. You should stick with either camelCase or underscore_separated, not mix_andMatch. You'll never remember how to write all of these variables once your code is more than a single page.
  15. Well it's your lucky day: There is no such thing as "alphanumeric order." You'll have to clarify. Natural order? ASCII order? Give examples. You could also order your query
  16. I haven't used "Excel proper" in many years, but I don't recall it having problems with unquoted values. In fact, "excel style CSVs" used to be randomly quoted, only receiving quotes when necessary, and being unquoted otherwise. OpenOffice Calc opened a quick 1,2,3,4,5 test right away, it just said "this looks like a CSV, is it?" I don't have Excel, since I don't run windows. Did it stop operating like that with the recent versions?
  17. I wasn't intending it to be, and I should have clarified in my first post that it was the dirtiest possible solution. Since the OP said he was making CSVs by copying and pasting the existing output, I assumed $data had no quotes or commas.
  18. OP has CSV-formatted output: echo $data[0] . "," . $data[1] . "," . $data[2] . "," . $data[3] . "," . $data[4] . "," . $data[5] . "," . $data[6] . "," . $data[7] . "," . $data[8] . "," . $data[9] . "," . $data[10] . "," . $data[11] . "," . $data[12] . "," . $data[13] . "," . $data[14] . "," . $data[15] . "," . $data[16] . "," . $data[17] . "," . $data[18] . "," . $data[19] . "," . $data[20] . "," . $data[21] . "," . $data[22] . "," . $data[23] . "," . $data[24] . "," . $data[25] . "," . $data[26] . "," . $data[27] . "," . $data[28] . "," . $data[29] . "," . $data[30] . "," . $data[31] . "," . $data[32] . "," . $data[33] . "," . $data[34] . "," . $data[35] . "," . $data[36] . "," . $data[37] . "," . $data[38] . "," . $data[39] . "," . $data[40] . "," . $data[41] . "," . $data[42] . "," . $data[43] . "," . $data[44] . "," . $data[45] . "," . $data[46] . "," . $data[47] . "," . $data[48] . "," . $data[49] . "," . $data[50] . "," . $data[51] . "," . $data[52] . "," . $data[53] . "," . $data[54] . "," . $data[55] . "," . $data[56] . "," . $data[57] . "," . $data[58] . "," . $data[59] . "," . $data[60] . "," . $data[61] . "," . $data[62] . "," . $data[63] . "," . $data[64] . "," . $data[65] . "," . $data[66] . "," . $data[67] . "," . $data[68] . "," . $data[69] . "," . $data[70] . "," . $data[71] . "," . $data[72] ."<br />\n"; He says he wants it in a file rather than having to copy/paste. The absolute quickest solution is to replace "echo" with "file_put_contents" and add the flag. Are we working off a different definition of "CSV"? Assuming there's no commas in any element of $data, it still would made made him a valid CSV file.
  19. If OP really is just finding a single tag and inserting something after it, regex is better (and faster) than DOM. Though it's going to become a religious argument if we keep talking about it.
  20. @both OP is new enough that efficiency and overall script access isn't an issue for them. copy/pasting their echo line and changing echo to file_put_contents is the absolute fastest way to their solution. Though, OP, if you're still here: They're right. it's the least efficient method, and I should have mentioned that in my original post.
  21. Someone's who's really good with regex can work magic on all sorts of problems. Parsing HTML is nothing. The only thing PHP's regex cannot handle is counting matched tags, or nested tags. If you need that, then the DOM is better, assuming the HTML is well-formed.
  22. It wasn't sarcasm, I always use regex to parse HTML. the DOM is undocumented (last I checked) and clunky (last I used it), and craps out on malformed HTML which renders perfectly in the browser. In fact, I worked for 3 years writing specialized web spiders in PHP without using the DOM once.
  23. With this vague of a question, I'll just say "regular expressions."
  24. Look into file_put_contents for spitting data to a file. If you use the file_append flag, you can put a f_p_c call after every echo and also spit this data out to a file.
×
×
  • 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.