SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Oct 2003
    Location
    Novi Sad
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Talking calling user defined functions within other function

    Something is pretty wrong with 'if' in this code inside the procedure
    film_ima_mesta:
    $br_m_b = 10;
    function ima_mesta($dan,$vreme) {
    $mesta = mysql_query("SELECT r.MESTO FROM rezervacija r WHERE
    r.VRM = '" . $vreme . "'
    AND r.DAN = '" . $dan . "'")
    or die('Greska u pricesiranju upita oko provere slobodnih mesta pr.');
    $br_mesta = mysql_num_rows($mesta);
    if ($br_mesta < $br_m_b) {
    return true;
    }
    else {
    return false;
    };
    }; ## ima_mesta


    function film_ima_mesta($kljuc_f) {
    $ok = false;
    $upit = "SELECT p.DAN, p.VRM FROM projekcija p WHERE
    p.IDF = '".$kljuc_f."'";
    $proj = mysql_query($upit) or die('Greska u obradi upita oko provere slobodnih mesta f.');
    while ($rez = mysql_fetch_array($proj)) {
    $dan = $rez[DAN];
    $vrm = $rez[VRM];
    $niz[1]= $dan;
    $niz[2]= $vrm;
    $ima = ima_mesta($dan,$vrm);
    if ($ima) {
    ##$ok = true;
    echo ($rez[DAN].'<br> ');
    echo ($rez[VRM].'<br> ');
    echo ($ima."h");
    };

    };
    ## return $ok;

    }; ## film_ima_mesta

    Please help me...

  2. #2
    SitePoint Zealot Arkkimaagi's Avatar
    Join Date
    Mar 2002
    Location
    Lappeenranta, Finland
    Posts
    176
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is not javascript. It looks more like php

    I cleaned it a bit if someone wants to take a peak:
    PHP Code:
    $br_m_b 10;
    function 
    ima_mesta($dan,$vreme) { 
      
    $mesta mysql_query("SELECT r.MESTO FROM rezervacija r WHERE r.VRM = '" $vreme "' AND r.DAN = '" $dan "'"
      or die(
    'Greska u pricesiranju upita oko provere slobodnih mesta pr.'); 
      
    $br_mesta mysql_num_rows($mesta);
      if (
    $br_mesta $br_m_b) {
        return 
    true;
      }
      else { 
        return 
    false;
      }; 
    };

    function 
    film_ima_mesta($kljuc_f) {
      
    $ok false;
      
    $upit "SELECT p.DAN, p.VRM FROM projekcija p WHERE p.IDF = '".$kljuc_f."'"
      
    $proj mysql_query($upit) or die('Greska u obradi upita oko provere slobodnih mesta f.'); 
      while (
    $rez mysql_fetch_array($proj)) {
        
    $dan $rez[DAN];
        
    $vrm $rez[VRM];
        
    $niz[1]= $dan;
        
    $niz[2]= $vrm;
        
    $ima ima_mesta($dan,$vrm);
        if (
    $ima) {
          echo (
    $rez[DAN].'<br> ');
          echo (
    $rez[VRM].'<br> ');
          echo (
    $ima."h"); 
        };
      };
    }; 

  3. #3
    SitePoint Wizard Defender1's Avatar
    Join Date
    Apr 2001
    Location
    My Computer
    Posts
    2,808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Take the semicolons out after the ending curly braces and see what you get.
    Defender's Designs
    I'm Getting Married!

    Not-so-patiently awaiting Harry Potter Book 7 *sigh*


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •