Jump to content

ziv

Members
  • Posts

    32
  • Joined

  • Last visited

    Never

Everything posted by ziv

  1. use preg_match_all() to extract your pattern. (click here for preg syntax)
  2. here all u need: http://help.joomla.org/api/Joomla/mosParameters.html
  3. i'm not sure...because in this case if you use http protocol, there is no benefits for the fopen().....
  4. this is the same as using file_get_contents() <?php $conetents = file_get_contents($file); ?> but if you have a memory problem (or performance) you should not load all this data into the memory.
  5. file(), file_get_contents() and so on...are a functions family that read the entire file into memory and you should not use them on large files. use instead fopen() and iterate on the data in a relatively small chunks.
  6. any iteration will cost you the same. so, using a for statement, or using array_walk (or similar) function will do the job.
  7. only on the end of the string. sha1() return 40 chars and base64_encode() increase the numbers of chars. that is the reason i wrote the function is limited to 40 chars length.
  8. something like this? <?php /** * @param int $length - max 40 chars (sha1 length) * @return string */ function getRandomPassword($length) { return substr( base64_encode( sha1( mt_rand() ) ), 0, $length); } // i used base64 encoding becouse it's convert any // data to letters (lowers and uppers) and numbers echo getRandomPassword(35); ?>
  9. you can use cronjob as scheduler to run a maintenance php script.
  10. simple oo php example: <?php <?php class ImageDetails { /** * all image details you need from your db. * use "mysql_fetch_object" to build your results as objects */ public function getName() { return 'x'; // image name for example... } } class ImageGallery { private $list; private $size; /** * @param array $list, list of images details * @param int $size, number of gallery collumns */ public function __construct($list, $size = 3) { $this->list = $list; $this->size = $size; } public function show() { $counter = 0; echo '<table border="1">'; foreach ($this->list as $image) { if ($counter == 0) { // open row echo '<tr>'; } $this->_printRow($image); ++$counter; if ($counter == $this->size) { // close row echo '</tr>'; $counter = 0; } } if ($counter != 0) { // padding the table $this->_paddTable($counter); } echo '</table>'; } private function _printRow($image) { // here you print the image in any form you want echo '<td>' . $image->getName() . '</td>'; } private function _paddTable($counter) { for ($i=$counter ; $i<$this->size ; ++$i) { echo '<td> </td>'; } } } // 'list of your images (ImageDetails objects) $list = array(new ImageDetails(), new ImageDetails(), new ImageDetails(), new ImageDetails(), new ImageDetails(), new ImageDetails(), new ImageDetails(), new ImageDetails(), new ImageDetails(), new ImageDetails()); $gallery = new ImageGallery($list); $gallery->show();
  11. try this code: <?php $xml = simplexml_load_file('your_xml_file'); $list = $xml->xpath('//dict/dict/dict/string[1]'); var_dump($list);
  12. change your php.ini directives: display_errors = On error_reporting = E_ALL
  13. lets take a look at your code: <?php function MYSQL_DATABASE_QUERY($SQL, $DB_Server) { $QUERY = mysql_query($SQL, $DB_Server) or die(mysql_error());# or die ("Failed Query"); return $QUERY; } are you sure you send to this function mysql-resource as the first parameter? if you use the return value of this function: <?php function CONNECT_MYSQL_DATABASE() { $host = "localhost"; #usually localhost $account = "<>"; # username for access. eg. root $password = "<>"; $db_name = "<>"; #name of database on the server that you want to connect. #global $db_type; #$db_type = 4.1; # MySQL version $DB_Server = mysql_connect($host, $account, $password) or die(mysql_error());# or die ("Cannot connect to a database. Please try again later"); $DB_Server = mysql_select_db($db_name, $DB_Server) or die("Cannot select the database. Please try again later."); return $DB_Server; } than you use a boolean value (the return value of mysql_select_db) as mysql-resource. you should return the return value of mysql_connect as mysql-resource.
  14. http://php.net/date_default_timezone_set
  15. the only way to get a data, is to send it. if you want php to get the selectbox data after it change, you can add an event to this element (onchange) that redirect the page (using javascript) and add the data to the query string (GET)
  16. mysql let you use spaces in the fields nme - but it is a bad habit. that is the way you can run your query: "select * from `links` where `$position`=1" and i hope the $position is field name....
  17. you can override your apache configuration (you can find the reference at http://apache.org) here an example of the configuration on apache 2: ErrorDocument 400 /path/to/your/404/error/document.html
  18. Session is unique per user! this code: <?php session_start(); $_SESSION['x'] = /* any data you want to store */; ?> will create a session file for each user-request (one per user). the user A will not see the value x of user B!
  19. http://php.net/metaphone http://php.net/soundex http://php.net/levenshtein http://php.net/similar_text
  20. pre tag is good for any pre-formated data (plain text) but if you want to convert it to simple html, you can use the nl2br() function. <?php $str = 'this is text with new line'; echo $str; //this is text with new line echo nl2br($str); //this is text<br />with new line ?>
  21. everything in this range? 3.668667446 is ok? you can use rnad() on 3500 to 4300 and divide the result by 1000 (and you can do the same thing for any other size...)
  22. On the server, you don't have the odbc extension (or it's not loaded)...
  23. why imagemagick and not GD? http://www.php.net/gd
  24. if you don't need the thousands comma, no problem: <?php echo number_format('1000.568', 2, '', '.'); // 1000.57
×
×
  • 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.