Hi! I am a newbie, and recently I have installed php, apache, and mysql on my computer. However, after type some codes the browers left ÈpartÈ of the php code on the brower. It almost seem like the browser doesnèt recognize the code or something.

below is what my browser shows

Bob's Auto Parts
Order Results
Order processed at '; echo date('H:i, jS F'); echo '

'; echo '

Your order is as follows:
'; $totalqty = 0; $totalqty = $tireqty + $oilqty + $sparkqty; echo 'Items ordered: '.$totalqty.'
'; if( $totalqty == 0) { echo 'You did not order anything on the previous page!
'; } else { if ( $tireqty>0 ) echo $tireqty.' tires
'; if ( $oilqty>0 ) echo $oilqty.' bottles of oil
'; if ( $sparkqty>0 ) echo $sparkqty.' spark plugs
'; } $totalamount = 0.00; define('TIREPRICE', 100); define('OILPRICE', 10); define('SPARKPRICE', 4); $totalamount = $tireqty * TIREPRICE + $oilqty * OILPRICE + $sparkqty * SPARKPRICE; echo 'Subtotal: $'.number_format($totalamount,2).'
'; $taxrate = 0.10; // local sales tax is 10% $totalamount = $totalamount * (1 + $taxrate); echo 'Total including tax: $'.number_format($totalamount,2).'
'; if($find == 'a') echo '

Regular customer.
'; elseif($find == 'b') echo '

Customer referred by TV advert.
'; elseif($find == 'c') echo '

Customer referred by phone directory.
'; elseif($find == 'd') echo '

Customer referred by word of mouth.
'; else echo '

We do not know how this customer found us.
'; ?> 

THis is the code that I used

<?php
  // create short variable names
  $tireqty = $_POST['tireqty'];
  $oilqty = $_POST['oilqty'];
  $sparkqty = $_POST['sparkqty'];
  $find = $_POST['find'];
?>
<html>
<head>
  <title>Bob's Auto Parts - Order Results</title>
</head>
<body>
<h1>Bob's Auto Parts</h1>
<h2>Order Results</h2>
<?php

echo '<p>Order processed at ';
echo date('H:i, jS F');
echo '</p>';

echo '<p>Your order is as follows: </p>';

$totalqty = 0;
$totalqty = $tireqty + $oilqty + $sparkqty;
echo 'Items ordered: '.$totalqty.'<br />';

if( $totalqty == 0)
{
  echo 'You did not order anything on the previous page!<br />';
}
else
{
  if ( $tireqty>0 )
    echo $tireqty.' tires<br />';
  if ( $oilqty>0 )
    echo $oilqty.' bottles of oil<br />';
  if ( $sparkqty>0 )
    echo $sparkqty.' spark plugs<br />';
}

$totalamount = 0.00;

define('TIREPRICE', 100);
define('OILPRICE', 10);
define('SPARKPRICE', 4);

$totalamount = $tireqty * TIREPRICE
             + $oilqty * OILPRICE
             + $sparkqty * SPARKPRICE;

echo 'Subtotal: $'.number_format($totalamount,2).'<br />';

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


if($find == 'a')
  echo '<p>Regular customer.</p>';
elseif($find == 'b')
  echo '<p>Customer referred by TV advert.</p>';
elseif($find == 'c')
  echo '<p>Customer referred by phone directory.</p>';
elseif($find == 'd')
  echo '<p>Customer referred by word of mouth.</p>';
else
  echo '<p>We do not know how this customer found us.</p>';


?>
</body>
</html>

I have also attached a file with the screenshot of what I see

here is my php report

PHP Version 5.2.6

System Windows NT TOO-PC 6.0 build 6000
Build Date May 2 2008 18:01:20
Configure Command cscript /nologo configure.js "--enable-snapshot-build" "--with-gd=shared" "--with-extra-includes=C:\Program Files (x86)\Microsoft SDK\Include;C:\PROGRA~2\MICROS~2\VC98\ATL\INCLUDE;C:\PROGRA~2\MICROS~2\VC98\INCLUDE;C:\PROGRA~2\MICROS~2\VC98\MFC\INCLUDE" "--with-extra-libs=C:\Program Files (x86)\Microsoft SDK\Lib;C:\PROGRA~2\MICROS~2\VC98\LIB;C:\PROGRA~2\MICROS~2\VC98\MFC\LIB"
Server API Apache 2.0 Handler
Virtual Directory Support enabled
Configuration File (php.ini) Path C:\Windows
Loaded Configuration File C:\Program Files\PHP\php.ini
PHP API 20041225
PHP Extension 20060613
Zend Extension 220060519
Debug Build no
Thread Safety enabled
Zend Memory Manager enabled
IPv6 Support enabled
Registered PHP Streams php, file, data, http, ftp, compress.zlib
Registered Stream Socket Transports tcp, udp
Registered Stream Filters convert.iconv.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, zlib.*

Zend logo This program makes use of the Zend Scripting Language Engine:
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies

PHP Credits
Configuration
PHP Core
Directive Local Value Master Value
allow_call_time_pass_reference Off Off
allow_url_fopen On On
allow_url_include Off Off
always_populate_raw_post_data Off Off
arg_separator.input & &
arg_separator.output & &
asp_tags Off Off
auto_append_file no value no value
auto_globals_jit On On
auto_prepend_file no value no value
browscap no value no value
default_charset no value no value
default_mimetype text/html text/html
define_syslog_variables Off Off
disable_classes no value no value
disable_functions no value no value
display_errors Off Off
display_startup_errors Off Off
doc_root no value no value
docref_ext no value no value
docref_root no value no value
enable_dl On On
error_append_string no value no value
error_log no value no value
error_prepend_string no value no value
error_reporting 6143 6143
expose_php On On
extension_dir ./ ./
file_uploads On On
highlight.bg #FFFFFF #FFFFFF
highlight.comment #FF8000 #FF8000
highlight.default #0000BB #0000BB
highlight.html #000000 #000000
highlight.keyword #007700 #007700
highlight.string #DD0000 #DD0000
html_errors On On
ignore_repeated_errors Off Off
ignore_repeated_source Off Off
ignore_user_abort Off Off
implicit_flush Off Off
include_path .;C:\php5\pear .;C:\php5\pear
log_errors On On
log_errors_max_len 1024 1024
magic_quotes_gpc Off Off
magic_quotes_runtime Off Off
magic_quotes_sybase Off Off
mail.force_extra_parameters no value no value
max_execution_time 30 30
max_input_nesting_level 64 64
max_input_time 60 60
memory_limit 128M 128M
open_basedir no value no value
output_buffering 4096 4096
output_handler no value no value
post_max_size 8M 8M
precision 14 14
realpath_cache_size 16K 16K
realpath_cache_ttl 120 120
register_argc_argv Off Off
register_globals Off Off
register_long_arrays Off Off
report_memleaks On On
report_zend_debug On On
safe_mode Off Off
safe_mode_exec_dir no value no value
safe_mode_gid Off Off
safe_mode_include_dir no value no value
sendmail_from no value no value
sendmail_path no value no value
serialize_precision 100 100
short_open_tag Off Off
SMTP localhost localhost
smtp_port 25 25
sql.safe_mode Off Off
track_errors Off Off
unserialize_callback_func no value no value
upload_max_filesize 2M 2M
upload_tmp_dir C:\Windows\Temp C:\Windows\Temp
user_dir no value no value
variables_order GPCS GPCS
xmlrpc_error_number 0 0
xmlrpc_errors Off Off
y2k_compliance On On
zend.ze1_compatibility_mode Off Off

any help would be appreciated!

the server isn't reading the php code. did you set up apache to work with php.

also, fyi the browser doesn't read php code, the server does.

the server isn't reading the php code. did you set up apache to work with php.

also, fyi the browser doesn't read php code, the server does.

yes I did set it up with apache

and these are the lines that I typed into the APACHE conf file

LoadModule php5_module "c:/Program Files/PHP/php5apache2_2.dll"
AddType application/x-httpd-php .php
PHPIniDir "c:/Program Files/PHP"

just checking: did you give the file a .php extension.

a lot of people make that mistake. hopefully you are not one of them.

The page isn't being parsed. Here are a few questions to varify:
1.) Are you sure Apache is running? (Check the Task Manager for Apache.exe)
2.) Are you testing the file under localhost? (Does the url say "http://localhost/filename.php" or does it say "C:/...")
3.) Is the php file saved in the htdocs folder?

There are many other possibilities but these are the common ones that are easily solved.

just checking: did you give the file a .php extension.

a lot of people make that mistake. hopefully you are not one of them.

Thanks for the quick reply!

Since I am new at this it is very possible that I will make common mistakes. I have given all files a .php extension, and infact the file I pulled out is an example from a cd in a php text book, so I am pretty sure they didnot do anything wrong.

Thanks again for the reply

to me it seems that the server only interprets part of the code since not all of it was left out.

for example if I type:

<?php

echo '<p>Order processed at ';
echo date('H:i, jS F');
echo '</p>';
_______________________________

THis would be the result shown on the browser:

echo '<p>Order processed at ';
echo date('H:i, jS F');
echo '</p>';

The page isn't being parsed. Here are a few questions to varify:
1.) Are you sure Apache is running? (Check the Task Manager for Apache.exe)
2.) Are you testing the file under localhost? (Does the url say "http://localhost/filename.php" or does it say "C:/...")
3.) Is the php file saved in the htdocs folder?

There are many other possibilities but these are the common ones that are easily solved.

Hi,

as for my answers to your questions:

1. Apache is running, I have check taskmanager and servers in administrator tools.
2. I am not testing it under localhost the url says c:..
3. I have not tried it in the htdocs folder, however I have tried it just now and it still displays parts of the code.

Tootol. I tested your script with both php and html extensions. When given a php extension, the file works perfect. When given an html extension, the file looks identical to the screen shot you provided. Make sure that you have the file saved in htdocs and are previewing through localhost.

Tootol. I tested your script with both php and html extensions. When given a php extension, the file works perfect. When given an html extension, the file looks identical to the screen shot you provided. Make sure that you have the file saved in htdocs and are previewing through localhost.

Hi buddylee! I have just placed the files into htdocs, opened my file by typing http://localhost/processorder.php it shows exactly how I wanted it to be. Thank for the help! however I still have a question, when I try to link the page to a submit form I created with <form action="processorder.php" method="post">. the preview of the php code still pops up with c:.. How do I fix it so it will pop up on localhostÉ

put all your php files in the htdocs then try again.

put all your php files in the htdocs then try again.

Thanks for the reply!

I have done what you told me and it is working perfectly right now! Thank you for your help! You have made my day :)

Welcome!Kindly mark this thread solved;)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.