BrentonHale Posted December 24, 2009 Share Posted December 24, 2009 Hi, I'm having trouble using a css template. It's not loading my header.html or footer.html files. Here is my code below and the error messages I receive. <?php # Script 3.5 - calculator.php $page_title = 'Widget Cost Calculator'; include ('/includes/header.html'); if (isset($_POST['submitted'])) { if ( is_numeric($_POST['quantity']) && is_numeric($_POST['price']) && is_numeric($_POST['tax']) ) { $taxrate = $_POST['tax'] / 100; $total = ($_POST['quantity'] * $_POST['price']) * ($taxrate + 1); echo '<h1 id="mainhead">Total Cost</h1> <p>The total cost of purchasing ' . $_POST['quantity'] . ' widget(s) at $' . number_format ($_POST ['price'], 2) . ' each, including a tax rate of ' . $_POST['tax'] . '%, is $' . number_format ($total, 2) . '.</p><p><br/></p>'; } else { echo '<h1 id="mainhead">Error!</h1> <p class="error">Please enter a valid quantity, price, and tax.</p><p><br/></p>'; } } ?> <h2>Widget Cost Calculator</h2> <form action="calculator.php" method="post"> <p>Quantity: <input type="text" name="quantity" size="5" maxlength="10"/></p> <p>Price: <input type="text" name"price" size="5" maxlength="10"/></p> <p>Tax (%): <input type="text" name="tax" size"5" maxlength=10"/></p> <p><input type"submit" name="submit" value="Calculate!"/></p> <input type="hidden" name="submitted" value="TRUE"/> </form> <?php include ('./includes/footer.html'); ?> Error messages are as follows: Warning: include(./includes/header.html) [function.include]: failed to open stream: No such file or directory in C:\wamp\www\calculator.php on line 4 Warning: include() [function.include]: Failed opening './includes/header.html' for inclusion (include_path='.;C:\php5\pear') in C:\wamp\www\calculator.php on line 4 Warning: include(./includes/footer.html) [function.include]: failed to open stream: No such file or directory in C:\wamp\www\calculator.php on line 56 Warning: include() [function.include]: Failed opening './includes/footer.html' for inclusion (include_path='.;C:\php5\pear') in C:\wamp\www\calculator.php on line 56 I use a program called WAMPSERVER which runs my apache, mysql and php. It's located on the harddrive at C:\wamp\www and that's where all my files go into. Not HTdocs. Could someone please tell me what exactly to type to get my header.html and footer.html files to load? Thank you and Merry Christmas! Link to comment https://forums.phpfreaks.com/topic/186258-php-css-help/ Share on other sites More sharing options...
Adam Posted December 24, 2009 Share Posted December 24, 2009 Clue's in the error: failed to open stream: No such file or directory. You're using a mix of relative and absolute paths to include the files. "./" = relative from the current directory "/" = absolute/root path of the server In respect to the file this code is in, where are the header and footer files stored? By the way, placing your code within code tags makes it easier to read Link to comment https://forums.phpfreaks.com/topic/186258-php-css-help/#findComment-983680 Share on other sites More sharing options...
BrentonHale Posted December 24, 2009 Author Share Posted December 24, 2009 Clue's in the error: failed to open stream: No such file or directory. You're using a mix of relative and absolute paths to include the files. "./" = relative from the current directory "/" = absolute/root path of the server In respect to the file this code is in, where are the header and footer files stored? By the way, placing your code within code tags makes it easier to read I apologize for not placing in the code tags. The header and footer files are stored C:\wamp\www Link to comment https://forums.phpfreaks.com/topic/186258-php-css-help/#findComment-983690 Share on other sites More sharing options...
Adam Posted December 24, 2009 Share Posted December 24, 2009 Then try: include './header.html'; // and.. include './footer.html'; Link to comment https://forums.phpfreaks.com/topic/186258-php-css-help/#findComment-983692 Share on other sites More sharing options...
BrentonHale Posted December 24, 2009 Author Share Posted December 24, 2009 Then try: include './header.html'; // and.. include './footer.html'; Excellent! Well done, it worked! Thank you and Merry Christmas! Link to comment https://forums.phpfreaks.com/topic/186258-php-css-help/#findComment-983694 Share on other sites More sharing options...
Adam Posted December 24, 2009 Share Posted December 24, 2009 No problem. Seemed you were trying to include them from the "includes" directory, which was of course wrong. Just need to check your paths in future.. Adam Link to comment https://forums.phpfreaks.com/topic/186258-php-css-help/#findComment-983697 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.