Jump to content

ziv

Members
  • Posts

    32
  • Joined

  • Last visited

    Never

Contact Methods

  • Website URL
    http://fat-fish.co.il

Profile Information

  • Gender
    Male

ziv's Achievements

Newbie

Newbie (1/5)

0

Reputation

  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)
×
×
  • 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.