Jump to content

Alex

Staff Alumni
  • Posts

    2,467
  • Joined

  • Last visited

Everything posted by Alex

  1. I'm gonna be honest, I'm not much more than a novice at regex myself, this will work, but probably isn't the most simplistic way. <?php function parseip($ip) { $s = explode('.', $ip); $s[2] = preg_replace('~(\d)~', '*', $s[2]); $s[3] = preg_replace('~(\d)~', '*', $s[3]); return implode('.', $s); } $ip = '82.132.196.45'; echo parseip($ip); //82.132.***.**
  2. Not exactly, there's really no need to test for flash compatibility because it's so widely supported these days with over 99% of users having support. Although, if you want to I suppose you could, I just don't think it's really necessary. As for a PHP method the only thing that I can think of would be extremely inefficient and not practical to impose on all visitors.
  3. The manual pretty much assumes that you already have knowledge of regular expressions, which is what the PCRE functions like preg_replace() use. You might want to read up on those.
  4. Alex

    get url?

    It's always a good idea to Google (or whatever search engine you prefer) what you're looking for before you post a topic. A simple search returns this page: http://www.webcheatsheet.com/PHP/get_current_page_url.php. function curPageURL() { $pageURL = 'http'; if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";} $pageURL .= "://"; if ($_SERVER["SERVER_PORT"] != "80") { $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; } else { $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; } return $pageURL; }
  5. I suppose you could do this all inside of flash. Using AS3 it would be easy to detect how long something is taking to load, if it takes longer than X seconds you can cancel the loading and just load the image you want to display inside of Flash.
  6. Are you sure the variables have a value?
  7. Single quotes don't parse variables. So you're using the literal string '$header', instead of the contents of the variable $header. Instead use no quotes, or double quotes.
  8. Here's a quick example I put together for you, this will create an image with the two things you provided: <?php // Set the Content-type to image/png to output a PNG image header('Content-type: image/png'); // Create a new image resource(49x49) $im = imagecreatetruecolor(49, 49); //Merge the Month image onto $im, which will be our final image. imagecopy($im, imagecreatefrompng('http://i36.tinypic.com/2vb1tso.png'), 0, 0, 0, 0, 49, 15); //Merge the Day image onto $im imagecopy($im, imagecreatefrompng('http://i37.tinypic.com/2rf6iy8.png'), 0, 15, 0, 0, 49, 34); // Output $im, the image resource imagepng($im); ?> Things you'll want to read up about: PHP GD Library imagecopy() imagecreatetruecolor() imagepng()
  9. Well it's clearly defined.. what if you try $("input#memo").val();?
  10. You could always use header('Location: '); and pass the url of their file in the query-string to get and display on a success page. eg. header('Location: success.php?file=' . $file_url); Then on success.php put something like: if(isset($_GET['file'])) { echo "Your file was successfully uploaded! URL: " . $_GET['file']; }
  11. According to your code posted previously it should work. All I modified was memo to message, and in that code message is defined. Post the new JS source, in code tags.
  12. Just as I suspected, look at this line: var dataString = 'fName='+ name + '&email=' + email + '&subj=' + subject + '&memo=' + memo; You're using memo, which is actually an object. You should be using the variable that you defined for the value of that object. Which is message, so it should be this: var dataString = 'fName='+ name + '&email=' + email + '&subj=' + subject + '&memo=' + message; Also, in the future you should use [ code ] or [ php ] (without the spaces) tags.
  13. You didn't really post the part of the code that's relevant to your problem. We'd need to see the AJAX portion of this. But because of the error I can tell you that your problem is almost certainly that you're passing the actual object into the HTTP request rather than the value of that element. So the solution would be to add ".value" to what you're passing to access the value attribute of the object. For a more specific solution you'll need to post the relevant code.
  14. Use the && operator. if(strlen($sentence) > 40 && strlen($sentence) < 155))
  15. The way to define a class is like: class Something { } Because the class itself doesn't take any parameters, rather any parameters being passed when instantiating the class are through the constructor.
  16. You're gonna want to look into sessions If you need an example just ask.
  17. Is the signature showing? If so then your query is fine and in that case I'm make sure that the row holding the post count is actually called 'post_count'.
  18. Use strtolower() to convert the string to all lower-case before array_split(). eg $setenceArray = str_split(strtolower($sentence));
  19. Your problem is that it's trying to actually parse $host as a variable, which has no value. So instead you should be using single quotes which don't parse variables. eg $stringData = '$host="localhost";' . "\n"; You could also make things easier on yourself and use file_put_contents() which acts the same way as fopen(), fwrite() and fclose(), just making it simpler for you.
  20. It's not very nice to insult people who are taking time out of their day to help you.
  21. When I wrote that example I expected you to write the rest, the actual writing to config.php. Ex: file_put_contents('config.php', $tpl);
  22. I can't seem to find any games that keep my attention these days.
  23. Then just change echo to $str = $str = (strpos($str, 'CATEGORY: ') !== false) ? next(explode(': ', $str)) : $str;
  24. You can use: echo (strpos($str, 'CATEGORY: ') !== false) ? next(explode(': ', $str)) : $str; Basically what it does is check to see if 'CATEGORY: ' is found inside $str using strpos(). If it does then it explodes and gets ITEM out of it, like in my previous example. If not it just echoes $str
×
×
  • 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.