Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Installation problem ?

Status
Not open for further replies.

bclt

Programmer
Mar 13, 2005
363
GR
Hi,

just installed php, edited the ini file and added the path "c:\php\" in the $PATH of the environment variables. I uninstalled apache and desiced to use IIS (v.5)(
Tried an example writting a php file in the localhost.The code is <? phpinfo() ?>. When i call it ( it responds correctly and show me info abou php... So php is working.

I have an example that does some actions (a+b, a-b); simple. The script is called and i expect to show the results... but the browser show me the php script code.


Any ideas?
 
Of course i can post it but no use. This code is the 1st example of a book i bought; there is no spell/syntax error because it was in the cd. Anyway:

Code:
<html>
<head>
  <title>Bob's Auto Parts - Order Results</title>
</head>
<body>
<h1>Bob's Auto Parts</h1>
<h2>Order Results</h2>
<? 
  echo "<p>Order processed at "; // Start printing order 

  echo date("H:i, jS F");
  echo "<br>";
  echo "<p>Your order is as follows:";
  echo "<br>";
  echo $tyreqty." tyres<br>";
  echo $oilqty." bottles of oil<br>";
  echo $sparkqty." spark plugs<br>";

  $totalqty = 0;
  $totalamount = 0.00;
 
  define("TYREPRICE", 100);
  define("OILPRICE", 10);
  define("SPARKPRICE", 4);

  $totalqty = $tyreqty + $oilqty + $sparkqty;
  $totalamount =  $tyreqty * TYREPRICE
                + $oilqty * OILPRICE
                + $sparkqty * SPARKPRICE;
  
  echo "<br>\n";
  echo "Items ordered:       ".$totalqty."<br>\n";
  echo "Subtotal:            $";
  echo number_format($totalamount, 2);
  echo "<br>\n";

  $taxrate = 0.10;  // local sales tax is 10%
  $totalamount = $totalamount * (1 + $taxrate);
  $totalamount = number_format($totalamount, 2);
  echo "Total including tax: $".$totalamount."<br>\n";

?>
</body>
</html>
 
Where are you getting your values for $tyreqty, $oilqty, $sparkqty? It seems to me they were submitted by a form. Which means your book is either old or not really good, because it assumes that register globals is on. They are turned off in recent versions of php due to security reasons. Check how your form is submitted -- if it is method get (variables in URL) use [tt]$_GET['tyreqty'][/tt] to fetch the value, if it is post, use [tt]$_POST['tyreqty'][/tt]. The same with all other variables that come from the form on previous page.
 
Yes.

It is at form action = "blabla.php" (post method)
It is mentioned in the book that i can also use $HTTP_POST_VARS["tireqty"]. I'll try changing them
 
It is not this the problem. Again it do not show me the page but the php code

?
 
A few silly questions:

1. How are you accessing the file? Is it a [tt]http[/tt] protocol (like or is it file? If it is file, php code will not be processed.
2. Is the filename of the php file .php?
3. Have you tried switching [tt]<?[/tt] to [tt]<?php[/tt]? The latter is the full version that works on every server while the first is shorthand which might be off.

This is all I can think of, since you say that phpinfo actually executes.
 
To make thing clearer:

If i write to the browser the script will be executed.
If i have <form action=file.php action=post> and hit submit the browser will show me the code..

1. I created the file like this: open notepad, wrote the code eg <? echo "<b>Hello</b>"; ?>, save the file as file.php. It is recognized as php file.

2. It is .php

3. I tried this but nothing
 
Hi again,

I transfered the files (php script and html page) via ftp to a real server and the script works fine!!!

The problem is at my pc; mean that apache do not work properly. Can anyone show me some lines i should change in the file httpd.conf ?

Tnx
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top