cb154 Posted July 13, 2010 Share Posted July 13, 2010 Hi I am having a real weird issue. I have a page that I want to do a conditional include in which is all working fine. However the included page ceases to work when included via a conditional variable for example if i do include 'myfile.php' all works fine if i assing myfile.php to $myfile then use include $myfile the included file stops working ? any thoughts. Quote Link to comment https://forums.phpfreaks.com/topic/207615-include-files/ Share on other sites More sharing options...
Pikachu2000 Posted July 13, 2010 Share Posted July 13, 2010 Code please? Quote Link to comment https://forums.phpfreaks.com/topic/207615-include-files/#findComment-1085383 Share on other sites More sharing options...
gwolgamott Posted July 13, 2010 Share Posted July 13, 2010 This should work, I've used that method for years with dynamic sites. Is it giving errors? Maybe the condition is never being set. Have you checked that... and yes code snippets for both ways you are doing this would be nice Quote Link to comment https://forums.phpfreaks.com/topic/207615-include-files/#findComment-1085386 Share on other sites More sharing options...
cb154 Posted July 13, 2010 Author Share Posted July 13, 2010 so this is the assignment <?php // assign the include depending on the option. if (isset($_POST['add'])) { $include = 'acquisitioninfo.php'; } else if (isset($_POST['edit'])) { $include = 'editsearchresults.php'; } else if (isset($_POST['submit'])) { $include = 'editsearchresults.php'; } else{$include ='editsearchresults.php';} ?> nothing untoward going on in there that I can see. I will also post the code from the include file as that is where the failure is happening. but the oddity is that if i just do it as a straight include .. then it works it only fails when I include via a variable Quote Link to comment https://forums.phpfreaks.com/topic/207615-include-files/#findComment-1085387 Share on other sites More sharing options...
cb154 Posted July 13, 2010 Author Share Posted July 13, 2010 This should work, I've used that method for years with dynamic sites. Is it giving errors? Maybe the condition is never being set. Have you checked that... and yes code snippets for both ways you are doing this would be nice The error I am getting is that is is not performing the insert, the include file contains a form which one filled in and submitted will redirect the user. Quote Link to comment https://forums.phpfreaks.com/topic/207615-include-files/#findComment-1085389 Share on other sites More sharing options...
PFMaBiSmAd Posted July 13, 2010 Share Posted July 13, 2010 Where's the most important line of code, the include statement? Quote Link to comment https://forums.phpfreaks.com/topic/207615-include-files/#findComment-1085390 Share on other sites More sharing options...
cb154 Posted July 13, 2010 Author Share Posted July 13, 2010 <?php require_once('../Connections/vinovotedb.php'); ?> <?php session_start(); if (isset($_GET['WineID'])) { $wineID = (get_magic_quotes_gpc()) ? $_GET['WineID'] : addslashes($_GET['WineID']); } else { if (isset($_POST['wineID'])) { $wineID = (get_magic_quotes_gpc()) ? $_POST['wineID'] : addslashes($_POST['wineID']); } } // lets get the year if (isset($_GET['Year'])) { $year = $_GET['Year']; } if (isset($Year)) { $year = $Year; } // setup all the variables needed. if (isset($_POST['WineID'])) { $id = $_POST['WineID']; } else { $id = $wineid; } $dateday = date("d"); $datemonth = date("m"); $dateyear = date("Y"); $vintage = $_POST['bottleVintage']; $usid = $_SESSION['MM_Username']; $quantity = $_POST['quantity']; $dateacquired = $_POST['day'].$_POST['month'].$_POST['year']; $price = $_POST['price']; $currency = $_POST['currencyCode']; $totalcost = $price; $winesize = $_POST['bottleSize']."ml"; $location = $_POST['storingInfo']; if (isset($_POST['wineryIsOtherParty'])){ } else { $purchase = $_POST['otherPartyName']; } if (isset($_POST['isOnOrder'])){ } else { } $alcohol = $_POST['alcohol']; $description = $_POST['description']; $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "CellarEntry")) { while($counter<$quantity) { $insertSQL = "INSERT INTO cellar (WineID, UserID,WineYear,Quantity,DateAcquired,Price,TotalCost,Currency,WherePurchased,LocationStored,Alcohol,Description,WineSize) values ('".$id."','".$usid."','".$vintage."','1','".$dateacquired."','".$price."','".$totalcost."','".$currency."','".$purchase."','".$location."','".$alcohol."','".$description."','".$winesize."')"; mysql_select_db($database_vinovotedb, $vinovotedb); $Result1 = mysql_query($insertSQL, $vinovotedb) or die(mysql_error()); $counter++; } printf("<script>location.href='mycellar.php'</script>"); } echo $quantity; ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <form action="<?php echo $editFormAction; ?>" method="POST" name="CellarEntry" target="_self" id="CellarEntry"> <tr><td colspan="4" class="titlepaddingbottom"></td> </tr> <tr> <td class="smallfieldlabel"> <table width="686" border="0"> <tr> <td width="141">Date:</td> <td width="291"> <input name="year" maxlength="4" size="4" value=<?php echo $dateyear ?> type="text"> / <input name="month" maxlength="2" size="2" value=<?php echo $datemonth ?> type="text"> / <input name="day" maxlength="2" size="2" value=<?php echo $dateday ?> type="text"></td> <td width="240"> </td> </tr> <tr> <td>Vintage:<span class="smallfieldvalue"> </span></td> <td><span class="smallfieldvalue"> <input name="bottleVintage" maxlength="10" size="6" value=<?php echo $year; ?> type="text"> </span></td> <td> </td> </tr> <tr> <td>Bottle Size </td> <td><span class="smallfieldvalue"> <input name="bottleSize" maxlength="10" size="6" value="750" type="text"> </span></td> <td> </td> </tr> <tr> <td>Quantity: </td> <td><input name="quantity" maxlength="20" size="10" value="1" type="text"></td> <td> </td> </tr> <tr> <td> Price</td> <td><span class="smallfieldvalue"> <input name="price" maxlength="20" size="10" value="0" type="text"> <select name="currencyCode"> <option value="CAD">CAD</option> <option value="ARS">ARS</option> <option value="AUD">AUD</option> <option value="BRL">BRL</option> <option value="CHF">CHF</option> <option value="CLP">CLP</option> <option value="EUR">EUR</option> <option value="GBP" selected>GBP</option> <option value="HKD">HKD</option> <option value="ILS">ILS</option> <option value="NZD">NZD</option> <option value="TRY">TRY</option> <option value="USD">USD</option> </select> each </span></td> <td> </td> </tr> <tr> <td>From</td> <td><span class="smallfieldvalue"> <input name="wineryIsOtherParty" value="on" type="checkbox"> Winery</span></td> <td><span class="smallfieldvalue">or <input name="otherPartyName" maxlength="75" size="28" value="" type="text"> </span></td> </tr> <tr> <td>On Order </td> <td><span class="smallfieldvalue"> <input name="isOnOrder" value="on" type="checkbox"> (select this if this is a future order.) </span></td> <td>Stored: <input name="storingInfo" maxlength="75" size="40" value="" type="text"></td> </tr> <tr> <td>Alcohol %:<span class="smallfieldvalue"> </span></td> <td><span class="smallfieldvalue"> <input name="alcohol" maxlength="10" size="6" value="" type="text"> </span></td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr> <tr> <td>Description</td> <td colspan="2" rowspan="2"><textarea name="description" cols="45" rows="6"></textarea></td> </tr> <tr> <td> </td> </tr> </table> </td> </tr><tr><td class="smallfieldvalue"> </td> </tr> <tr> <td class="smallfieldlabel"> </td> </tr><tr><td class="smallfieldlabel" valign="top"> </td> <input type="hidden" name="WineID" value="<?php echo $wineID; ?> <td colspan="3"><BR> <input type="submit" id="search-submit" value="Save to Cellar" /> <input type="hidden" name="MM_insert" value="CellarEntry"> </form> </body> </html> this is the include file that is not working when included via a varable as opposed to a straight include 'myfile.php' Quote Link to comment https://forums.phpfreaks.com/topic/207615-include-files/#findComment-1085392 Share on other sites More sharing options...
gwolgamott Posted July 13, 2010 Share Posted July 13, 2010 This should work, I've used that method for years with dynamic sites. Is it giving errors? Maybe the condition is never being set. Have you checked that... and yes code snippets for both ways you are doing this would be nice The error I am getting is that is is not performing the insert, the include file contains a form which one filled in and submitted will redirect the user. I see, thought you were doing something like this: if($something==$somethinelse) { include("something.php"); } You method should work, is it doing it just for that one include only? whats the include look like something like this? include($include); or include("$include"); let's take a peek at that, but if it's only doing it for one of the files... hmmm. Quote Link to comment https://forums.phpfreaks.com/topic/207615-include-files/#findComment-1085397 Share on other sites More sharing options...
cb154 Posted July 13, 2010 Author Share Posted July 13, 2010 This should work, I've used that method for years with dynamic sites. Is it giving errors? Maybe the condition is never being set. Have you checked that... and yes code snippets for both ways you are doing this would be nice The error I am getting is that is is not performing the insert, the include file contains a form which one filled in and submitted will redirect the user. I see, thought you were doing something like this: if($something==$somethinelse) { include("something.php"); } You method should work, is it doing it just for that one include only? whats the include look like something like this? include($include); or include("$include"); let's take a peek at that, but if it's only doing it for one of the files... hmmm. just include ($include); is what I am doing. it is just this include that doesn't work when performed in this way. Quote Link to comment https://forums.phpfreaks.com/topic/207615-include-files/#findComment-1085401 Share on other sites More sharing options...
cb154 Posted July 13, 2010 Author Share Posted July 13, 2010 also if i do it via your method it still does not work Quote Link to comment https://forums.phpfreaks.com/topic/207615-include-files/#findComment-1085403 Share on other sites More sharing options...
gwolgamott Posted July 13, 2010 Share Posted July 13, 2010 did u solve it? Quote Link to comment https://forums.phpfreaks.com/topic/207615-include-files/#findComment-1085439 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.