Jump to content

kicken

Gurus
  • Posts

    4,704
  • Joined

  • Last visited

  • Days Won

    179

Everything posted by kicken

  1. The proper way (one of a few anyway) to define a function within a function that is in an object literal would be like this: var myObject = { myFunc:function (){ var myOtherFunc=function(){ }; } }; I'm not sure if that is what you're looking for though. It's hard to tell from your partial code samples and text what exactly it is you're trying to accomplish.
  2. Note you can just use the bitshift operators too. echo (1<<0) . PHP_EOL; //1 echo (1<<1) . PHP_EOL; //2 echo (1<<2) . PHP_EOL; //4 echo (1<<3) . PHP_EOL; //8 echo (1<<4) . PHP_EOL; //16 //... The expression y<<x moves the bits in y x places to the left. When y is 1 (pattern 00000001) then you're just moving the one bit x place. eg 1<<5 would be (00100000)
  3. That code is entirely pointless. You're converting "Hello\r\nHow are you?"; into "Hello<br />\r\nHow are you?"; using the first line (nl2br) and then back to "Hello\r\nHow are you?"; using the second line (str_replace). Just remove both lines and leave $string as it originally was, same effect. A textarea element will properly understand and display text with the new line characters ("\r\n"). So when put into a text area the string "Hello\r\nHow are you?"; will be displayed as: Hello How are you? You only need to add the br tags using nl2br when you are displaying the text inside some other HTML element like a paragraph or div tag.
  4. I would be too. I was thinking more along the lines of the editor picking up the define() lines and adding the constants to a list, then it could just auto-complete constant names for you. So if you were typing out Return_Web_Content($blah, RETU An editor could infer that the 'RETU' is a prefix to a constant and show a list of such constants as auto-complete options.
  5. Your cleansafelynow function doesn't actually do anything the way you have it written. You never save the results of those function calls back to $var so all you're doing is returning the same exact data you passed into the function. function cleansafelynow($var) { if (get_magic_quotes_gpc()){ $var=stripslashes($var); } $var=strip_tags($var); $var=htmlspecialchars($var, ENT_QUOTES); return $var; }
  6. Rather than number them 1, 2, 3, etc just generate a unique string. Either using the current time value, or something like uniqid. If you want to make sure the generated name doesn't exist, keep generating a new name in a loop so long as file_exists returns true.
  7. The closest you could get probably would be to use defined constants. A smart editor *might* be able to pick those up and offer them as completion suggestions. define('RETURN_RESPOSNECODE', 1); define('RETURN_FULLHEADER', 2); define('RETURN_FULLBODY', 3); function Return_Web_Content($url, $what){ switch ($what){ case RETURN_RESPONSECODE: ...; break; case RETURN_FULLHEADER: ...; break; case RETURN_FULLBODY: ...; break; } }
  8. Sure, you could do that. stream_socket_server
  9. Depending on what your needs are using stream_select may allow you to to other processing while waiting for user input. I've never tried it with the STDIN stream though, only sockets. There is also the readline and ncurses extensions that you may find handy for CLI development.
  10. while($products[]= mysql_fetch_array($result_products,MYSQL_ASSOC)); Runs in a process like this: 1) Get a value from mysql_fetch_array 2) Store that value into $products array 3) Is the value we just got false? - No, go to step 1 - Yes, go to step 4 4) Exit loop Where as this code: while($product = mysql_fetch_array($result_products,MYSQL_ASSOC)) $products[] = $product; Runs in a process like this: 1) Get a value from mysql_fetch_array 2) Store the value into $product 3) Is the value we just got false? - No, go to step 4 - Yes, go to step 5 4) Add $product to $products array 5) Exit loop
  11. The output is the Warning message you're getting about invalid arguments. When you fix that, the headers already sent error will go away too.
  12. Why do you have visit_detail at all if it is just a duplicate of the other columns? Why not just remove the column all together and if that field is required, require them to check at least one of the other boxes?
  13. You're missing your condition for your else if() branch. The if below it has extra ( and no ){ at the end. If you just re-structure it a little bit the code becomes easier to read and follow too. if (!in_array($_SERVER['REMOTE_ADDR'], $whitelist)) { if (@fsockopen($_SERVER['REMOTE_ADDR'], 80, $errstr, $errno, 1) || @fsockopen($_SERVER['REMOTE_ADDR'], 8080, $errstr, $errno, 1) || @fsockopen($_SERVER['REMOTE_ADDR'], 3128, $errstr, $errno, 1)){ echo "Banned"; } }
  14. You're still technically supposed to encode the & inside urls. Browsers don't have any issues if you don't though. href="mailto:hello@domain.com?subject=my+subject+here&body=this+is+the+body" would be correct for the validator and with URL encoding.
  15. I assumed as much, but your captcha script does not include that file. Unless that is in code you did not post.
  16. Did he tell you, or do you know how many splitters are between the modem and the main line? We had a problem with our on-demand on the TV not working after moving into this place. I was able to re-route the cable to only go through one splitter by the main line and that solved the issue. Could cause issues with modems too if there are a couple in the path. Definitely shouldn't be too hard to run a new cable though if that is what it takes to get things fixed up.
  17. Have you tried it via telnet from an external source, such as a VPS somewhere or an online port scanner? Many residential service ISP's block port 25 so if you're running this on that type of connection that may be your issue. If that's not the problem you'll have to provide some more details/code. On a different note, why are you trying to write a SMTP server using PHP when there are plenty of perfectly good servers already available?
  18. I don't see a session_start() call anywhere in your captcha image generation script. You'll need that for your $_SESSION variable to work.
  19. I personally would have the code generate a SQL script (or several) which will let you do a quick review of the data before trying to import it to ensure things are correct. Depending on how much data translation you need to do in order to convert from one board to the other you might be able to get away w/ just using a INSERT INTO ... SELECT query and not have to mess with PHP at all.
  20. You would create a rewire rule that passes the title of the movie to a script, then you use that title to lookup the movie. Eg: RewriteRule /watch/(.*)$ movie.php?title=$1 Then in movie.php you would use $_GET['title'] to query the database for the movie and display it. You'll need to make sure all your titles are unique for each movie in order to find the proper one. An alternative would be to do like the forums here do and stick the ID and the title in the URL. Eg: /watch/1234-my-movie Then you would not need to have a unique title because you can look them up by the ID, but you still get a nicer looking URL. A rule like this should handle that type of setup: RewriteRule /watch/(\d+)-.*$ movie.php?id=$1
  21. Note that some extensions have multiple periods (eg bbc.co.uk). If you're concerned about domains like that you'll need to create a list of all the possible TLDs to test against.
  22. Run the explain query in something like phpMyAdmin or the mysql console utility where it will just dump the result set for you.
  23. If you bind to 0.0.0.0 then it will bind to all available IPv4 addresses. There is probably something similar for IPv6 but I do not know it off the top of my head. To sort of address the question in a general sense though, I'm pretty sure you'd need one socket for each protocol. If you wanted to bind specific addresses rather than "all addresses" I'm pretty sure you'd need a socket for each address/port combo.
  24. I'm assuming you're talking about the page http://www.superdupersites.com/strange/page_2.php since the one you linked only contains the text 'page 2' once in the nav bar. The reason it is displaying that way is because of your display: inline-block; definition that you have set on the table (via the .rounded-corners class). It is causing the table's body to only fill the minimum required space rather than the whole width of the page.
  25. You'll have to figure out which query is slow to run and try to speed it up, most likely through adding indexes. Take each of those queries and put EXPLAIN in front of them, then run them in a tool like mysql console or phpMyAdmin. Mysql will tell you how it is executing the queries, what indexes (if any) it is using and some other information about the query. You can use that information to decide how to speed up the queries. If you need help interpreting the results of the EXPLAIN post both the query and the results here.
×
×
  • 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.