Jump to content

marun

New Members
  • Posts

    7
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

marun's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. <?php $phrase = file_get_contents('http://www.google.com/search?hl=lv&q=loan+student&btnG=Mekl%C4%93t&meta='); $Poz1 = strpos($phrase, "height=25"); echo ($Poz1); $Poz2 = strpos($phrase, "[/url]</h2><table"); echo $Poz2; $Cip = &Poz2 - $Poz1; /* can't I just use - ? */ ---------^ you have & and should be $ echo substr($phrase, $Poz1 , $Cip); /* so whats wrong with these 2 lines ? */ ?>
  2. Constant is not a singleton and singletons are not a pattern which should be used for tracking constants. Define is not bad. It just should be used wisely. It is like makros in C. Many will say it is bad and never should be used but other will give plenty of examples where you can use them. Define should be used project wide config files which will be never changed. This values shouldn't be set by user. They shouldn't be computed. define('PI',3.14) If you need some constant inside a code you should use const keyword. http://pl2.php.net/manual/en/language.oop5.constants.php Configuration shouldn't be some global. If configuration of site is simple (not too many options) it can be one singleton with __get function. If it is complicated I would create set of singletons one for each group of options. Ex: DatabaseConfiguration PathConfiguration ... Each class will be keeping track of its data. Is it file, database or whatever. In a big project some options probably will be taken from file, some from database and some computed. Site Config, class or global? Singleton and data should be stored outside php.
  3. Think about header() as special kind of echo(). Difference is header must be before any output other echo, printf,etc. Pdf files can't be inlined into html files. If you need access from page to pdf files create link in in html page wich will be pointing to your pdf file (script wich will generate pdf). If you must have pdf and html on one site you can try frames/iframes but how it will behave is browser+pdfreader dependant.
  4. marun

    ORDER BY

    bool is alias for tinyint(1) in MySQL so I guess it will work.
  5. Yuo should change your regexp: $review = preg_match('/[!@#$%^&*()]/', $input); This will match when any of '!@#$%^&*()' will be present at $input.
  6. Add date filed to the database and sort result by date.
  7. marun

    ORDER BY

    1. Easiest way is probably make a few queries. -> Select sticky topics ordered by ... -> Select normal topics ordered by ... -------------------- 2. If table is something like: create table Message(id integer auto_increment, sticky bool, locked bool, PRIMARY KEY(id)); To sort in order: 1. Sticky and locked. 2. Sticky and unlocked 3. Unsticky and unlocked 4. Unsticky and locked SELECT * FROM Message ORDER BY sticky DESC, IF(sticky AND locked, true, false) DESC, IF(NOT STICKY AND LOCKED, true, false) ASC; For data set: +----+--------+--------+ | id | sticky | locked | +----+--------+--------+ | 1 | 0 | 0 | | 2 | 0 | 1 | | 3 | 1 | 0 | | 4 | 1 | 1 | | 5 | 1 | 0 | | 6 | 0 | 1 | | 7 | 1 | 1 | | 8 | 0 | 0 | +----+--------+--------+ It will produce output: +----+--------+--------+ | id | sticky | locked | +----+--------+--------+ | 4 | 1 | 1 | | 7 | 1 | 1 | | 3 | 1 | 0 | | 5 | 1 | 0 | | 1 | 0 | 0 | | 8 | 0 | 0 | | 2 | 0 | 1 | | 6 | 0 | 1 | +----+--------+--------+
×
×
  • 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.