Page 1 of 1

Advice on why a problem has happened

Posted: Wed Jan 27, 2010 10:28 am
by ReaCt3Rr
So im new to php and have been working on differnet tuts for the past few days today tho I hit a snag, and have now a bigger problem!

Can annoyone tell me why I am getting this:

"222.4", "Candle Stick" => "4", "Coffee Table" => "80.6"); echo "

";
printf("%-20s%20s\n", "Name", "Price");
printf("%'-41s\n", " ");
foreach ($products as $key=>$val) {
printf("%-20s%20.2f\n", $key, $val );
}
echo "

"; ?>


instead of what i should be getting from this code:

Code: Select all

      <?php
       $products = array("Green Chair" => "222.4", "Candle Stick" => "4", "Coffee Table" => "80.6");
       echo "<pre>";
       printf("%-20s%20s\n", "Name", "Price");
       printf("%'-41s\n", " ");
       foreach ($products as $key=>$val) {
               printf("%-20s%20.2f\n", $key, $val );
       }
       echo "</pre>";
       ?>
This is happening with each of my files, so I thinking I may have done something in th .ini file by accident...I really hope not though! Any help at all will be appriciated

R

Re: Advice on why a problem has happened

Posted: Wed Jan 27, 2010 10:58 am
by timWebUK
I got this output when using your code:
Name Price
----------------------------------------
Green Chair 222.40
Candle Stick 4.00
Coffee Table 80.60
So for your peace of mind there is nothing wrong with it, however I've no idea what would be causing a problem like the one you're getting.

Re: Advice on why a problem has happened

Posted: Wed Jan 27, 2010 12:12 pm
by requinix
Your script isn't being executed by PHP. Check that you've installed and configured everything properly.

Re: Advice on why a problem has happened

Posted: Thu Jan 28, 2010 2:50 am
by ReaCt3Rr
thanks guys, after editing the configs i hadnt reloaded apache...new it would be something simple :P ty