Jump to content

Function not running right from another folder


Recommended Posts

i have my php files in folders, in the top directory, "patterns" I have a file "index.php" that needs access to a file in the sub folder "model".

so structure is patterns/model

 

so from the file in patterns i use

include_once("model/preview_post.php");

 

which should access the file and it does, i can write an simple echo at the top, and it pops out, however when i call a function it stops half way through and doesn't echo anything out after a certain point.

Now you might think this is just a bug in the function but calling the function from inside this file results in the correct output and even moving "index.php" model folder results in the function completing. but moving it out of the folder stops the function running correctly.

 

so to clarify when the function is called from inside itself it runs, when its called from another file which is in the same folder it runs, but when its called from another file in another folder it doesn't run the whole way through.

 

Any ideas? i do realize this has been very generalized.

 

Thanks

 

 

 

I have tried this on two rigs and mac and PC, so can rule out PHP init problems

 

 

index.php

*********************************************

 

include_once("model/preview_post.php")

set_up_preview_model(0, "calum", "date", "");

 

*********************************************

 

 

model/preview_posts.php

 

*********************************************

include_once("../controllers/posts.php");

include_once("../controllers/medias.php");

include_once("../controllers/side_panels.php");

include_once("media_markup.php");

include_once("validation.php");

include_once("post_mkup.php");

 

  /*gets post in order of newest */

  function set_up_preview_model($_page_no, $_ses_user, $_html_page, $_arg1){

  $_page_no = is_it_integer($_page_no);

 

  if ($_html_page == "date"){

  $bag_of_posts = display_posts_by_date($_page_no, $_arg1);

  echo "in HERE";

  }

  else if($_html_page == "recently_active"){

  $bag_of_posts = display_posts_by_recently_active($_page_no);

  }

  else if($_html_page == "category"){

  $bag_of_posts = display_posts_by_category($_page_no, $_arg1);

  }

  else if($_html_page == "score"){

  $bag_of_posts = display_posts_by_score($_page_no);

  }

  else if($_html_page == "tags"){

  $bag_of_posts = display_posts_by_tags($_page_no, $_arg1);

  }

  else if($_html_page == "rated_by"){

  $bag_of_posts = display_posts_by_rated_by($_page_no, $_arg1);

  }

  else if($_html_page == "created_by"){

  $bag_of_posts = display_posts_by_created_by($_page_no, $_arg1);

  }

markup_model($bag_of_posts, $_ses_user, $_html_page);

  }

 

 

*********************************************

 

 

Kind of worked out it gets through there ok, the problem is when it leave this file through this function to get to include_once("../controllers/posts.php"); obv the index.php the post file is include_once("controllers/posts.php"); so removing the ../ makes it get into the posts.php file but i dont want to have to remove it, ive done this loads of time and never had an issue

 

model/preview_posts.php

 

*********************************************

  //defualt is the newest posts first

  function display_posts_by_date($_page_no, $_order){

  $bag_of_posts = get_posts_by_date($_page_no, $_order);

print_r($bag_of_posts);

return $bag_of_posts;

}

*********************************************

 

 

 

 

 

i havnt read this much because i cant stand the no [ code ] tag :D

but have you noticed that you have

 

index.php
*********************************************

include_once("model/preview_post.php")
set_up_preview_model(0, "calum", "date", "");

 

you said preview_posts.php on your post but here it says post... maybe this is your problem

Archived

This topic is now archived and is closed to further replies.

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