african_bob Posted May 11, 2008 Share Posted May 11, 2008 Hi, Im new to using php and im having difficulty passing a paramter via the include_once method. I have a page which implements paging so each time a user clicks on the next button it calls the same page but with a new page number .e.g <a href=\"javascript:goToPage('paging.php?page=$page','lists');\">[Next]</a> This works fine when i just use the href without the include_once function. Any suggestions on how i can fix this? Thanks Link to comment https://forums.phpfreaks.com/topic/105167-passing-parameter-using-include_once/ Share on other sites More sharing options...
BlueSkyIS Posted May 11, 2008 Share Posted May 11, 2008 how are you trying to use include_once()? can we see code? Link to comment https://forums.phpfreaks.com/topic/105167-passing-parameter-using-include_once/#findComment-538440 Share on other sites More sharing options...
african_bob Posted May 11, 2008 Author Share Posted May 11, 2008 ya sure, if($pagePost != "") { //If page is index.php then include the home.php page //Else include the page specified if($pagePost == "index.php") { include_once("home.php"); } else { include_once($pagePost); } } Link to comment https://forums.phpfreaks.com/topic/105167-passing-parameter-using-include_once/#findComment-538453 Share on other sites More sharing options...
BlueSkyIS Posted May 11, 2008 Share Posted May 11, 2008 okay, i don't see anything odd there. you don't need to pass parameters to an included() file. it's like copying the code in the included file and pasting it where the include() is. what is the problem you are having? Link to comment https://forums.phpfreaks.com/topic/105167-passing-parameter-using-include_once/#findComment-538459 Share on other sites More sharing options...
african_bob Posted May 11, 2008 Author Share Posted May 11, 2008 this is the goToPafe function i use; function goToPage(page, headerText) { var masterPage = "index.php"; //var destinationPage = masterPage +"?page="+page; var str = "Masterpage:"+masterPage+" Page:"+page; document.forms['navigationForm'].action = masterPage; document.forms['navigationForm'].page.value = page; document.forms['navigationForm'].headerText.value = headerText; document.forms['navigationForm'].method = "POST"; document.forms['navigationForm'].submit(); } Link to comment https://forums.phpfreaks.com/topic/105167-passing-parameter-using-include_once/#findComment-538503 Share on other sites More sharing options...
african_bob Posted May 11, 2008 Author Share Posted May 11, 2008 the problem im having is that when i try pass the parameter using the gotoPage function the function sees the string and paramater and thinks its the name of a file and looks for that file however i want it to recognise that im passing a parameter This is the warning i get; Warning: include_once(paging3.php?page=2) [function.include-once]: failed to open stream: No such file or directory Link to comment https://forums.phpfreaks.com/topic/105167-passing-parameter-using-include_once/#findComment-538509 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.