Jump to content

Alex

Staff Alumni
  • Posts

    2,467
  • Joined

  • Last visited

Everything posted by Alex

  1. http://en.wikipedia.org/wiki/Mod_deflate
  2. Use the $argv array to get arguments passed to the script from the CLI.
  3. I'm assuming you're fetching from a database. ... $row = mysql_fetch_assoc($result); if(!empty($row['image_field'])){ // ... } else if(!empty($row['default_image'])){ // ... } else { // ... }
  4. <br> is an html line break. If you wanted to remove those instead use: str_replace("<br>", '', ...); Or if you want to remove both literal and html line breaks: str_replace(array("\n", '<br>'), '', ...);
  5. As premiso said, it depends. If it returns the excerpt something like this will do: echo str_replace("\n", '', the_excerpt()); If it echos the excerpt something like this will work: ob_start(); the_excerpt(); echo str_replace("\n", '', ob_get_clean());
  6. The second is correct. You just don't have any cookies set.
  7. Sorry, HtmlString += "<a href='#' onclick=\"AddDrink('" +title+ "','" + drink + "');\" >Add</a> <br>";
  8. It would be best if you could post you code so we can see if perhaps you're doing something wrong. You might want to reevaluate your circumstances and see if you really need timed events. For example, you mention checking to see if someone should be removed from the ban list every X seconds. This doesn't sound necessary. You could just check to see if the user is banned or if his ban period is over when he attempts to login (or connect, however you're identifying the ban). In the case you find it is necessary to have timed events and you can't get pcntl_alarm() working despite implementing it correctly you might want to look making socket_select non-blocking by supplying the optional timeout parameter(s). This way it will return after a certain period of time, and not block indefinitely perhaps solving your problem.
  9. If title and drink are strings they'll need quotes. HtmlString += " <a href='#' onclick='AddDrink(\'"+title+"\',\'"+drink+"\')'; >Add</a> <br> ";
  10. Whoops, I had a typo. You also had a problem with your HTML. function selectMenu(VALUE) { var HTML = ''; for(var VAL = 0; VAL <= VALUE; VAL++) { HTML += 'Choice ' + VAL + '<input type="text" name="field' + VAL + '" /><br />'; } document.getElementById('selects').innerHTML = HTML; }
  11. You would use += because unlike PHP where to concatenate strings you use . in JavaScript you use +. function selectMenu(VALUE) { var HTML = ''; for(var VAL = 0; VAL <= VALUE; VAL++) { HTML =+ 'Choice ' + VAL + '<input type="text" name="field"' + VAL + '" /><br />'; } document.getElementById('selects').innerHTML = HTML; }
  12. Any method that you use to make them seem to come out to 100% would only make things even less accurate and as a result make the system look even worse. Look around to see how other popular applications handle this problem. In most cases I think you'll find that they either show some decimals (SMF polls for example) or just leave it as is, I don't really think it's a big deal.
  13. There's nothing necessarily wrong with that.. You're rounding, by definition this means it won't be as accurate. Look at the numbers: 1 : 61.3275613..% becomes 61% (loss of .3275613..%) 2 : 25.3968254..% becomes 25% (loss of .3968254..%) 3 : 13.2756133..% becomes 12% (loss of .2756133..%) If you want it to be more accurate you can have it round to some decimal places. Ex: echo round(65.34654, 2); // 65.35
  14. You should never use $_SERVER['PHP_SELF'] as your form action, it leaves you vulnerable to XSS attacks. It's a better idea to just type the name of the file.
  15. When fetching a remote file it typically won't be very fast. In my experience I haven't found there to be much of a time difference between cURL and file_get_contents, but you can give it a shot.
  16. Try this: $result = mysql_query("SELECT concepto, numventa FROM tbl_nimpuestos WHERE numventa = '$z' "); $row = mysql_fetch_assoc($result) $tax1 = $row['concepto']; $tax2 = $row['numventa'];
  17. That will work fine, as you're redirecting after the MySQL query. It's also a good idea to always place exit; after a header redirect to ensure the execution of the script is stopped.
  18. You can use preg_replace_callback. $str = 'Here is a long "test string that" also contains quotes. It actually has "multiple quotes"'; $newstr = preg_replace_callback( '~"(.+?)"~', create_function( '$match', 'return str_replace(" ", "_", $match[0]);' ), $str ); echo $newstr;
  19. require_once and include_once have more overhead than require and include. In most cases the slight overhead isn't something you should concener yourself with because of how small it is. You should use what is best for your specific situation. If you have a case where a file only needs to be included once, and shouldn't be included more than once, use include_once or require_once.
  20. $amt = 24578; $payments = $amt > 10000 ? array_fill(0, floor($amt / 10000), 10000) : array(); $payments[] = $amt % 10000; print_r($payments);
  21. Yes, it should be a numeric datatype.
  22. What datatype is the temp column?
  23. I'm not entirely sure what your main question is. Yes. Yes, use sessions
×
×
  • 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.