Jump to content

Mark Baker

Members
  • Posts

    1,592
  • Joined

  • Last visited

    Never

Everything posted by Mark Baker

  1. Depends what you math is for. Simply use round or number_format to control the number of decimal place if you just want to echo the result. If these are monetary values, then it's always a lot better to hold the values as an integer number of cents/pennies rather than a float dollars/pounds: doing all of your math using integers won't give any rounding errors. Use the bc math functions, as the Warning message suggests
  2. Pay particular heed to the Warning on this page
  3. user the headers() function to set the appropriate header information to tell the browser that it's getting a csv file rather than html.... then echo out your csv content PS get rid of '<br />'. That's purely html. For a csv file you want a line feed "\n" instead
  4. Check that your SQL queries do actually return data using PHPMyAdmin or similar
  5. $rcount = $db->execute("SELECT SUM(quantity) as'' FROM items WHERE player_id = '$player->id'"); $rcount is likely to be a resource (a database result) rather than an actual integer value. You need to read your value from the result set. Why as''?
  6. You're breaking from the switch conditions, which ends the switch clause.... but your while ($row = mysql_fetch_array($result)) {echo "|" . $row['CountryName']; line is actually before the } that closes the switch, but after the breaks
  7. It's a bitwise operator, and you have to think about the data as a series of binary bits (rather than its ordinary datatype). e.g a number like 43, $a = 43; which in binary is 101011, (32 + 8 + 2 + 1) with leading zeroes giving 00000000000000000000000000101011 (to 32-bits if it's an integer on a 32-bit platform). what shift left does is shifts every bit to the left, adding a new 0 value bit as the right-most bit, and losing the existing left-most bit. If we shift left just once, we get 00000000000000000000000001010110 which is the binary value for 86 (64 + 16 + 4 + 2)
  8. How do you identify which entry needs to be next to what other entry?
  9. You can use the magic __isset method to validate whether an attribute exists or not, calling it within your magic getters/setters. PS 100 attributes is a lot, do you really need that many?
  10. <?php echo '<td><a href="product_details.php?productid='.$_POST[$productid].'">' .$productname.'</a>';?>
  11. I'd recommend the PHPExcel library listed in my sig, but you'd need to upgrade PHP on your server as well... although I'd recommend that too PHP4 really is very old now)
  12. World Wide Web Consortium (W3C) founded, Netscape Navigator 1.0 (IE 1.0 wasn't yet available) released, WebCrawler (the first web search engine)
  13. for($i=0; $i<1000; ++$i) { $formattedi = str_split(str_pad($i,4,'0',STR_PAD_LEFT)); sort($formattedi); $formattedi = implode('',$formattedi); if ($formattedi == $i) { echo $formattedi.'<br />'; } }
  14. Alternatively, why not simply use $numbers = range(1,20); shuffle($numbers) to give yourself a randomly shuffled array of numbers
  15. I'm not familiar with the psxlsgen class, and I'd recommend you switch to use a library that is still actively supported. However, I'm intrigued by this line: $this->WriteText_pos( $this->crow, $this->ccol, &$value ); What version of PHP are you using? Or is the psxlsgen class using? because passing by reference in this manner is deprecated.
  16. Running the application on your own servers as a managed service is also an option you might consider
  17. Within the funWrite() function, $a isn't defined when you compare it against the string "QUIT;", so it is not equal and your comparison is always true... therefore it displays the syntax error message
  18. The MySQL software is a real database server, so you can create your own databases using it
  19. darkvengance's approach requires a Windows webserver with Excel installed in order to use COM. If you need a pure PHP solution that will run on any platform, then a library like PHPExcel will allow you to create/populate an Excel worksheet directly from PHP
  20. Escape the quote in Da Corleone's (mysql_real_escape_string)
  21. Not to mention there's plenty of scripts in the Tests directory, showing how to instantiate a workbook, populate and format cells, and write out the file
  22. That's definitely more interesting, and I'll look forward to seeing it when you're ready
  23. I suspect he was, but I wanted some clarification before offering any solution
×
×
  • 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.