64Pacific Posted February 21, 2010 Share Posted February 21, 2010 Hello: Did a quick search, came up with nothing. Here is the problem, I have two websites, running on the same server, both running the same version of PHP and the same version of mySQL. One the first page, everything is working properly, or so I think. I set a few variables using a POST from another page, I then define a function, that has no arguments specified, it then returns one value using the variables set via POST. Later in the code I call the function. Everything sets itself properly. On my other page, I do exactly the same thing, unless I am missing something that I have done differently, my code does not return any values. I then tried passing values using arguments with no luck. The code is below, with chunks of it removed... This works: //Load the database configuration file, and setup the connection to the database and error handling require_once ('config.php'); //Obtain the values from the previous form $Method = $_POST['Method']; //Determine how we should set the year and month, from the member-index page or via today's date if ($Method == '') { //Get todays date month and year for the photo of the month addition $Year = date("Y"); $Month = date("m"); } else { //Set the date based on the values from the form $Month = $_POST['Month']; $Year = $_POST['Year']; } /** * Define the function to create the common part of the form */ function funCreateCommonForm() { //Define the common parts of the form $CommonForm = '<table id="InfoTable"> <tbody> <tr align="center"> <th colspan=2>Add a PoTM</th> </tr> <tr> <td>Photo number: <font color="red"><strong>*</strong></font></td> <td><input name="Photo" type="text" size="15" maxlength="6" value="' . $Photo . '"></td> </tr> <tr> <td>Month: <font color="red"><strong>*</strong></font></td> <td><input name="Month" type="text" size="15" maxlength="2" value="' . $Month . '"></td> </tr> <tr> <td>Year: <font color="red"><strong>*</strong></font></td> <td><input name="Year" type="text" size="15" maxlength="4" value="' . $Year . '"></td> </tr> <tr align="center"> <td colspan="2"><input type="submit" value="Place Entry"></td> </tr> </tbody> </table>'; //Return the value return $CommonForm; } /** * End of function definition */ //Determine what the form should do if ($Method == '') { //NEW REGISTRY ENTRY //Define the page title $page_title = 'Create A Photo of the Month Entry'; //Call the function to create the common parts of the form $CommonForm = funCreateCommonForm(); //Define the rest of the form $form = '<form name="PoTMForm" method="post" action="potm-exec.php">' . $CommonForm .'<input name="Method" type="hidden" class="textfield" value="New"></form>'; } Any ideas why this is working on one page, but the similarly coded page doesn't work? Quote Link to comment https://forums.phpfreaks.com/topic/192830-php-functions-working-differently/ Share on other sites More sharing options...
sader Posted February 21, 2010 Share Posted February 21, 2010 And which not works? Quote Link to comment https://forums.phpfreaks.com/topic/192830-php-functions-working-differently/#findComment-1015726 Share on other sites More sharing options...
PFMaBiSmAd Posted February 21, 2010 Share Posted February 21, 2010 my code does not return any values Nothing is returned from the function or the HTML produced in the function is returned without the values where the php variables are at or you get a completely blank page? Quote Link to comment https://forums.phpfreaks.com/topic/192830-php-functions-working-differently/#findComment-1015727 Share on other sites More sharing options...
64Pacific Posted February 21, 2010 Author Share Posted February 21, 2010 Yeah I receive the entire contents of the page, with the exception of the $CommonForm variable. I am using PHP template pages to layout the look of the page/site, I don't think I included the include statement for in my post... Quote Link to comment https://forums.phpfreaks.com/topic/192830-php-functions-working-differently/#findComment-1015739 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.