Announcement

Collapse
No announcement yet.

y do false functions stop my script?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • y do false functions stop my script?

    i have a function, and it needs the variable 'pid' to work.

    PHP Code:
    // Function to take basic template and put the title and information into it
    function displaypage($pid=-1){
        global 
    $queries;

        if(
    $pid != -1){
            
    // Get page info
            
    $queries->query("SELECT * FROM br_announce WHERE pid=$pid");
            
    $info_array mysql_fetch_array($queries->query);

            
    // Get template
            
    $queries->query("SELECT * FROM br_layouts WHERE lid=2");
            
    $template mysql_fetch_array($queries->query);

            
    $pagetoecho str_replace("<%title%>"$info_array[0], $template[1]);
            
    $pagetoecho str_replace("<%body%>",  $info_array[1], $pagetoecho);
            return 
    $pagetoecho;
        }


    if i don't include the variable pid or it doesn't exist, then as i'd expect, the function does nothing.

    but y does it stop everything below it?
    PHP Code:
    echo displaypage($pid);

    echo 
    displaymenu();

    echo 
    displaynews(); 
    it stops both displaymenu() and displaynews() from being executed

  • #2
    maybe it is because you didn't tell it to return? just a guess, but if pid=-1 then it should run right through that function. must be something else.

    I can't see that it would stop other functions from running.

    Comment


    • #3
      PHP Code:
      function displaypage($pid=-1){
          if(
      $pid != -1){
              global 
      $queries;
              
      // Get page info
              
      $queries->query("SELECT * FROM br_announce WHERE pid=$pid");
              
      $info_array mysql_fetch_array($queries->query);

              
      // Get template
              
      $queries->query("SELECT * FROM br_layouts WHERE lid=2");
              
      $template mysql_fetch_array($queries->query);

              
      $pagetoecho str_replace("<%title%>"$info_array[0], $template[1]);
              
      $pagetoecho str_replace("<%body%>",  $info_array[1], $pagetoecho);
              return 
      $pagetoecho;
          }

      if i put the global variable within the IF then it works, i duno, o well

      Comment


      • #4
        PHP Code:
        function displaypage($pid=-1){
            global 
        $queries;
            if(
        $pid != -1){
                
        // Get page info
                
        $queries->query("SELECT * FROM br_announce WHERE pid=$pid");
                
        $info_array mysql_fetch_array($queries->query);

                
        // Get template
                
        $queries->query("SELECT * FROM br_layouts WHERE lid=2");
                
        $template mysql_fetch_array($queries->query);

                
        $pagetoecho str_replace("<%title%>"$info_array[0], $template[1]);
                
        $pagetoecho str_replace("<%body%>",  $info_array[1], $pagetoecho);
                return 
        $pagetoecho;
            }
            return 
        0;

        That'll return false if it doesn't work...

        Comment


        • #5
          it turned out i was being a retard and put die() in my class, so that everytime sumthing was wrong it ended the script.

          darn

          Comment

          widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
          Working...
          X