Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
|
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 27th, 2006, 06:38 AM
Registered User
 
Join Date: Jun 2006
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default USING INCLUDE FIEL

  I HAVE THEY CODE WHICH HAS AN ERROR PLS GIVE ME THE CORRECT CODING OF THIS

THANKS:
<html>
<body>

<?php
require("wrongFile.php");
echo "Hello World!";
?>

</body>
</html>


ALSO THIS ONE:
<?php
// Enable all error reporting
error_reporting(E_ALL);
require_once('calc.conf');
// Get inputs from GET or POST request
$num1 = (! empty($_REQUEST['num1'])) ? $_REQUEST['num1'] : null;
$num2 = (! empty($_REQUEST['num2'])) ? $_REQUEST['num2'] : null;
$operator = (! empty($_REQUEST['operator'])) ?
$_REQUEST['operator'] : null;
// Set errors to null
$errors = null;
// If number 1 is not given, error occurred
if ($num1 == null)
{
$errors .= "<li>You did not enter number 1.";
}
// If number 2 is not given, error occurred
if ($num2 == null) {
$errors .= "<li>You did not enter number 2.";
}
// If operator is not given, error occurred
if (empty($operator)) {
$errors .= "<li>You did not enter the operator.";
}
// Set result to null
$result = null;
// If operation is + do addition: num1 + num2
if (!strcmp($operator, '+'))
{
$result = $num1 + $num2;
// If operation is - do subtraction: num1 - num2
} else if(! strcmp($operator, '-')) {
$result = $num1 - $num2;
// If operation is * do multiplication: num1 * num2
} else if(! strcmp($operator, '*')) {
$result = $num1 * $num2;
// If operation is / do division: num1 / num2
} else if(! strcmp($operator, '/')) {
// If second number is 0, show divide
// by zero exception
if (! $num2) {
$errors .= "Divide by zero is not allowed.";
} else {
$result = sprintf("%.2f", $num1 / $num2);
}
}
// Create a new template object
$t = new Template($TEMPLATE_DIR);
// Set the template file for this
// object to application's template
$t->set_file("page", $OUT_TEMPLATE);
// Setup the template block
$t->set_block("page", "mainBlock" , "mai");
// Set the template variable = value
$t->set_var("ERRORS", $errors);
$t->set_var("NUM1", $num1);
$t->set_var("NUM2", $num2);
$t->set_var("OPERATOR", $operator);
$t->set_var("RESULT", $result);
// Parse the template block with all
// predefined key=values
$t->parse("main", "mainBlock", false);
// Parse the entire template and
// print the output
$t->pparse("OUT", "page");
?>

THANK YOU FOR YOUR COOPERATION.....

 
Old August 8th, 2006, 08:01 AM
Friend of Wrox
 
Join Date: Nov 2005
Posts: 223
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Can you please turn of capslock that is very impolite.

So what seems to be the error I don't see any and what are you trying to solve.

__________________________________________________ ________
This is my junk I'm gona eat it





Similar Threads
Thread Thread Starter Forum Replies Last Post
A form field list populating based on another fiel ebburks Access 2 June 3rd, 2006 09:37 AM
difference between include file & include virtual crmpicco Classic ASP Basics 2 January 23rd, 2006 11:50 AM
Creating an Excel File from .NET with numeric fiel neilwillby VB.NET 2 December 12th, 2005 04:19 PM
multiple listbox selections written to a text fiel pascoag Access 0 October 14th, 2004 10:01 PM
Forms -- how to return to the same record and fiel tcarnahan Access 1 June 10th, 2003 11:24 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.