Jump to content

JasonLewis

Members
  • Posts

    3,347
  • Joined

  • Last visited

Everything posted by JasonLewis

  1. Haven't tried it, but recently came across Chaw. Hasn't been updated recently, but it sounds nice.
  2. Not really digging the large bold fonts being used. Hard to read for me. I too am getting that MySQL error mentioned. I'm viewing this site from Australia if that makes a difference. Your background appears to change slightly at a join of what looks like the header and the actual background. You can see it here in this screenshot, and I've blown it up a bit for clarity. It's very noticeable on the actual site.
  3. That does make sense though eh, possibly why I've never heard of it.
  4. As far as I know you can't 'send' a cookie to another site, but you can set the cookie to that sites domain. Refer to the setcookie() manual entry and look at the 'domain' parameter. You may be able to set the same cookie a few times and just alter the domain you are setting it for. But as I said, not 100% sure on that one.
  5. Pretty sure this is the coolest thing since Pokemon.
  6. Under Profile > Account Settings you surely can. Sounds like you plan on registering a new account though with your e-mail address.
  7. Your not setting a Content-Length header either, perhaps add that is as well. header("Content-Length: " . filesize($this->file));
  8. Well testing your script on my machine, setting the variables manually, produces the desired result. So your code is fine, something isn't right with your input/output.. :-\
  9. If it is possible then yes look for something JavaScript related. There may be something written for jQuery that would do it. I'll go for a Google soon, pretty sure I've seen something like that in the past.
  10. So they are all empty strings, yet you want to run the if statement if all of them are NOT EMPTY. Is that right? From the code you've given, assuming all the variables mentioned are in fact not empty, the if statement should be triggered fine. However if one is empty then of course the statement will return false.
  11. Quick overview: = is an assignment operator. You use it to assign values to variables, as you may have experienced. == is a comparison operator. Checks if variable is EQUAL TO another variable. === is a comparison operator. Checks if variable is IDENTICAL to another variable. So the main difference between the last to is that one checks the type as well, such as boolean or string etc. Example: $var1 = "true"; $var2 = true; if($var1 == $var2){ echo "var1 is equal to var2"; } if($var1 === $var2){ echo "This will not be echo'd, because var1 is not identical to var2"; } As you can see, $var1 is a string and $var2 is a boolean. So they are not identical. Hope that makes sense, and for further reference you can check out Comparisons at the manual. EDIT: Just a bit more of an explanation. The stripos() function isn't the best example of when you should use type comparison as well. Check out strpos(). Say you want to find the occurance of something in a string, and it's position is at the start. strpos() would return 0, because it's the first character. If you were to check if strpos() returned false, 0 would match this and your script would essentially think that it did not find a match when it in fact did. Here's an example: $string = "Hello World"; if(strpos($string, "Hello") == false){ echo 'Did not find "Hello"'; // This will be echo'd because "Hello" is at the start of the string (0) and 0 is equal to false. Bummer. } To overcome this problem, we need to check that the returned value of strpos() is identical to false, that is, the returned value is false itself, and not 0. $string = "Hello World"; if(strpos($string, "Hello") === false){ echo 'Did not find "Hello"'; // Now this won't be echo'd, because we are checking if they are identical. } Good luck.
  12. Perhaps one of them is actually empty hm? Check your inputs and outputs, see if they are what you expect. It's the first step of debugging. Oh and just to be sure, empty deems the following to be classified as 'empty':
  13. I've never heard of your #2 statement, although it could be true. Who knows. I'd doubt it. I sometimes do my returns like this too: if(strlen($x) > 10){ return $x; } return false; Just a personal thing.
  14. Could you elaborate a tad bit more please? Re-reading your questions leaves me even more confused.
  15. You have an unexpected variable. Check the quotes you used to start the string and the quotes around your variable $userid.
  16. Like what was said above, however you must remember to call session_start() on all pages that will be using sessions.
  17. From the MySQL documentation: Your query is saying limit to 36, starting from record 18. Which is why it is returning the rows until 54. Because it's starting at 18, adding 36... which equals 54.
  18. Using $this->$mdb2 will generally result in a notice, telling you that $mdb2 is undefined (or whatever variable you put). To access class properties you do not need to prefix it with the $ symbol. If you had a variable $mdb2 and it's value was "localhost" (just an example), then it would actually be saying $this->localhost. Example: class Test { public $foo = "Hello"; public function __construct(){ $bar = "foo"; echo $this->$bar; //will echo Hello } }
  19. First thing, when replacing multiple spaces I like to use something like: $user_input = preg_replace("/\s+/", " ", $user_input); Same thing, just a bit neater. Back to the main question. For each file you're going to either loop over each keyword, or for each keyword you're going to loop over each file. It's a matter of determining which would allow better results. Hard to say, but I'd probably try looping over each keyword for every file. So... $files = glob("path/to/files/*"); $keywords = preg_replace("/\s+/", " ", trim($user_input)); $keywords = explode(" ", $keywords); foreach($files as $file){ $contents = file_get_contents($file); foreach($keywords as $word){ // search the files $contents for $word here and store in a multi-dimensional array } } Now if you're after all occurances and the position of each inside the file you'd need to use strpos(), and make use of the 3rd parameter which allows an offset to where you start the search. You'd need to store each location inside an array that relates to that file, so you can highlight each match. You'll end up with some pretty big multi-dimensional arrays depending on the search and amount of files. If you need more help let us know. Good luck.
  20. There are a fair few topics around about this, try searching. Here are a few good results. http://www.phpfreaks.com/forums/php-coding-help/date-difference-295142/msg1397605/#msg1397605 http://www.phpfreaks.com/forums/php-coding-help/difference-between-dates-273176/msg1290174/#msg1290174 Shouldn't be hard to tailor it to your needs really. Just a matter of converting dates to UNIX timestamp, subtracting then divide that by 60*60*24 (86400, which is 1 day in seconds). Then round, ceil or floor it.
  21. Use the JavaScript date object. var date = new Date(); rand = date.getTime(); See how you go with something along those lines.
  22. Because it's not valid CSS 2.1. Sure it'll work, and it's quite valid, but @font-face has only really gained support in Firefox and Opera within the last few years. It's the same when doing things like border-radius, or -moz-border-radius and what not. Don't fret to much.
  23. The error you stated in your first post clearly points out that your MySQL is not working. If mysql_fetch_array() is telling you that the 1st parameter is not a valid resource, your query is failing which means you have an error somewhere in your query.
  24. When you send the request try appending a random number or the current timestamp to the URL, avoiding the caching.
×
×
  • 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.