Jump to content

.josh

Staff Alumni
  • Posts

    14,780
  • Joined

  • Last visited

  • Days Won

    43

Everything posted by .josh

  1. Though that technically works, I thought I'd tell you why it works, as well as how to do it better. the dot (.) is the concatenation operator. It is javascript's equivalent of the plus sign (+). So looking at your original attempt of: $mysql = $mysql + " Person "; It really should have been $mysql = $mysql . " Person "; That is to say: concatenate the current value of $mysql and the string " Person " and assign the result to $mysql. A better way to do it that doesn't require as much resources and time, is to use the shorthand version: $mysql .= " Person "; This says: append the string " Person " to the end of $mysql. The advantages to this are: - Code is shorter shorter (less code to be parsed), so the script executes faster. - Concept is less abstract. If you visualize a string variable as lego blocks being stacked up. It's easy to visualize just adding another block or two on top of the tower you're building (or whatever kids build these days). Using the same lego blocks analogy with the previous example $mysql = $mysql . " Person ";, you would have to visualize your current tower of blocks, build another one that's a copy of it. Add the new blocks to that. And then move the new tower to the other tower's place and get rid of the other tower. So you see, it's easier to visualize what's going on in the code with the shorthand version. - Less resource consuming. The computer is just adding more legos to the existing tower, instead of taking the time and effort to build another tower and all that noise. Here's the solution you came up with: $mysql = $mysql .= " Where Name like '%$SearchA%' "; This is even worse than doing $mysql = $mysql . " Person "; This code causes a copy of $mysql to be created twice. The computer has to perform two separate operations in your code. The inner operation is to concat the string to $mysql but first php has to make a copy of $mysql to do that inner operation. Then another temp var is made, which is the result of that inner operation. Then it is finally using in the outer operation, by being assigned to the original $mysql. Note: differences in execution time, memory/resource consumption, etc.. are negligible. Your computer probably has a dim idea of the difference, as it might struggle to perform the math at that kind of precision. You and your users certainly will not notice the difference. So saying your solution is "bad" wouldn't entirely be fair. But it is the difference between good code and great code.
  2. I thought that was standard practice in the U.S. ??? And if that doesn't work, we just label you a terrorist because you not letting me get my way is an act of terrorism. And then we send in the troops and bombs and take your country over, and then just take what we want, for free. So we can either do this the easy way, or the hard way. Either way is fine with us; your choice. Thank you for shopping U.S.A Corp. Have A Nice Day!
  3. Read this tutorial to learn how pagination works. Then you should be able to easily integrate pagination into your script.
  4. so what's the problem.
  5. We get requests for post (or certain info posted; usually links to their site)/thread/account deletion all the time. Threatening on top of that doesn't happen that often, but it does happen.
  6. Note: that is not guaranteed. PHPSESSID is the default cookie name for the default cookie that is set when a session is created. You can easily make your own cookie name that holds the session id, or not depend on the cookie at all. Regardless though, it will not reveal other details about a current session (like variables being used, what info they hold). Those are stored on the server by default or in a database if the site is written to store them there. And even if you do find a PHPSESSID cookie, the session id will most likely be encrypted.
  7. [...] as Daniel0 suggested [...] Wasn't me oops, my bad. I meant thorpe. Far be it from you to ever suggest some lame site like w3.org
  8. I tried googling hypertext transfer protocol specifications as Daniel0 suggested and I got absolutely nothing. NOTHING! wtf is up with that? You would think something would come up. I mean first off a frickin' wikipedia entry is first on the list. That just proves what a bunk service google is, because we all know the lack of value in wikipedia. And the 2nd entry is from some place called w3.org. And I do see that thorpe's link did come up as 3rd listing, which is also a page from this w3.org place. But wtf is that w3.org? Is that some kind of script kiddie lingo for "we"? 'we' what? Stupid kids these days, with their wes and 'wiis' and 'wee'. Is it really too much to have a learnaboutheaders.com show up when I go to google? If google wants to make it as a company they need to get on the ball with this searching thing. Otherwise they are just gonna be another no name company run into the ground.
  9. okay so you have 3 numbers. Those numbers symbolize red, green, blue. From black to blue is 0,0,0 to 0,0,255. from blue to white is 0,0,255 to 255,255,255. You will want to keep the first 2 numbers as the same to change the shade of the bluescale.
  10. echo the data as the element's value. example: // code retrieves address from db and puts it into $address echo "Address: <input type = 'text' name = 'address' value = '$address'>";
  11. what format are you using for this grayscale? give an example number.
  12. imo you shouldn't have data stored in your db formatted, simply because that makes your design capabilities less flexible. For instance, if you store all your names as <b>somename</b> and later on you don't want to have them bolded, you're going to have to go through each entry and remove the tags.
  13. other than the fact it is variable length, is that the only thing on the line, or is this thing being regexed from within a larger string?
  14. Go find a website that specializes in publicizing (alleged) fraud. Our community and internet presence will not be exploited by this crap. Thread closed.
  15. well it *could* be serious if the rest of your site depends on info gathered from the file_get_contents...
  16. You can't fix that sort of thing. He has no control over some 3rd party site. The 'better' thing to do would be to suppress it and check if it failed or not (as I showed in previous post)
  17. you could always suppress it and check what $country is: $country = @file_get_contents("http://api.hostip.info/country.php?ip=".$ip); if ($country) { // success, do something } else { // fail, do something }
  18. The error tells you what's wrong. you make a call to file_get_contents to a url and it failed, because there was a 500 error at that url.
  19. ah you know what, in the code I posted you can try adding an s modifier to the preg_match_all: preg_match_all('~<em>(.*?)</em>~s', $content, $matches); problem might be that your em content spans across multiple lines...
  20. http://us3.php.net/manual/en/function.print-r.php#77958
  21. I think you are misunderstanding. There is no such thing as sorting alphabetically vs. numerically. I think you are talking about sorting by key vs. value.
  22. sorting numerically versus...what?
  23. I used arsort(), which maintains key=>value pairs and sorts by value. Unless I'm mistaken he wants to sort by key...
  24. really because when I run the code I posted I get 1000 => value2 999 => value1 998 => value3 Is that not what you want?
  25. What is the point in asking whether something will work or not? Just try it. $array = array(999 => 'value1', 1000 => 'value2', 998 => 'value3'); krsort($array); foreach($array as $key => $val) { echo "$key => $val <br/>"; }
×
×
  • 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.