no error but no display
Moderator: General Moderators
-
honoey_let004
- Forum Newbie
- Posts: 6
- Joined: Fri Mar 20, 2009 4:18 am
no error but no display
Hi! im a newbie of Php, i need help i used sample source code in my book and in some site but there is no display when i view it in browser .. .i cant fix the problem .. .
here is the sample of the code i used:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3ort/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<title>numbers</title>
</head>
<body>
<?php
#script 1.9 numbers.php
//select the variables
$quantity = 30; //buying 30
$price = 119.95 // $119.95
$taxrate = 0.5; // 5%
// calculate the total.
$total = $quantity * $price;
$total = $total + ($total * $taxrate); //add tax
$total = number_format ($total, 2); // format the results
//print the results
echo "You are purchasing <b>", $quantity, '</b>widget(s) at a cost of <b>$', $price. '</b>
each. With tax, the total comes to <b>$', $total, '</b>.';
?>
</body>
</html>
pls help i really want to learn php, i want to make point of sales in my retail business.
thank u so much . ..
honeylet
here is the sample of the code i used:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3ort/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<title>numbers</title>
</head>
<body>
<?php
#script 1.9 numbers.php
//select the variables
$quantity = 30; //buying 30
$price = 119.95 // $119.95
$taxrate = 0.5; // 5%
// calculate the total.
$total = $quantity * $price;
$total = $total + ($total * $taxrate); //add tax
$total = number_format ($total, 2); // format the results
//print the results
echo "You are purchasing <b>", $quantity, '</b>widget(s) at a cost of <b>$', $price. '</b>
each. With tax, the total comes to <b>$', $total, '</b>.';
?>
</body>
</html>
pls help i really want to learn php, i want to make point of sales in my retail business.
thank u so much . ..
honeylet
-
Paul Arnold
- Forum Contributor
- Posts: 141
- Joined: Fri Jun 13, 2008 10:09 am
- Location: Newcastle Upon Tyne
Re: no error but no display
You've missed a semi-colon here:
$quantity = 30; //buying 30
$price = 119.95; // $119.95
$taxrate = 0.5; // 5%
To view errors you need to turn on error reporting. Have a look on Google for how to do this.
$quantity = 30; //buying 30
$price = 119.95; // $119.95
$taxrate = 0.5; // 5%
To view errors you need to turn on error reporting. Have a look on Google for how to do this.
-
honoey_let004
- Forum Newbie
- Posts: 6
- Joined: Fri Mar 20, 2009 4:18 am
Re: no error but no display
i already check error reporting and its on . .. and i add the semicolon which i missed but sir here is the result in browser . . .
", $quantity, 'widget(s) at a cost of $', $price. ' each. With tax, the total comes to $', $total, '.'; ?>
pls help . .. .
", $quantity, 'widget(s) at a cost of $', $price. ' each. With tax, the total comes to $', $total, '.'; ?>
pls help . .. .
Re: no error but no display
Your error reporting might not be set to a high enough level, try putting this at the top of your document:
Also, it's much easier to read the code, and therefore diagnose any issues, if you wrap it in code tags 
Code: Select all
<?php
error_reporting(E_ALL);
?>
-
honoey_let004
- Forum Newbie
- Posts: 6
- Joined: Fri Mar 20, 2009 4:18 am
Re: no error but no display
another one i try . ..
<html>
<head></head>
<body>
Agent: So who do you think you are, anyhow?
<br />
<?php
// print output
echo 'Neo: I am Neo, but my people call me The One.';
?>
</body>
</html>
display was . ..

i does not display php script output only the html output . .
pls help how to fix this problem ..
thanks
<html>
<head></head>
<body>
Agent: So who do you think you are, anyhow?
<br />
<?php
// print output
echo 'Neo: I am Neo, but my people call me The One.';
?>
</body>
</html>
display was . ..

i does not display php script output only the html output . .
pls help how to fix this problem ..
thanks
Last edited by honoey_let004 on Fri Mar 20, 2009 7:05 pm, edited 1 time in total.
Re: no error but no display
Your code appears quite badly formatted:
And again, PLEASE wrap your code in
Code: Select all
echo "You are purchasing <b>", $quantity, '</b>widget(s) at a cost of <b>$', $price. '</b>
each. With tax, the total comes to <b>$', $total, '</b>.';
Code: Select all
echo "You are purchasing <b>".$quantity."</b>widget(s) at a cost of <b>$".$price."</b>each. With tax, the total comes to <b>$".$total."</b>";
Code: Select all
tags.Re: no error but no display
I have just realised what your problem is. Looking at your screenshot, all your doing is loading the file. It needs to be run from a webserver, with PHP installed.
Try something like xampp: http://www.apachefriends.org/en/xampp-windows.html
PHP is a server side language, and therefore requires a server platform to run.
Try something like xampp: http://www.apachefriends.org/en/xampp-windows.html
PHP is a server side language, and therefore requires a server platform to run.
-
honoey_let004
- Forum Newbie
- Posts: 6
- Joined: Fri Mar 20, 2009 4:18 am
Re: no error but no display
I am currently using XAMPP i've also test myPhpAdmin and its working also the Apache . . . 
Re: no error but no display
you need to place your files in the htdocs directory of xampp, make sure its running, and then type http://localhost/myfile.php
-
honoey_let004
- Forum Newbie
- Posts: 6
- Joined: Fri Mar 20, 2009 4:18 am
Re: no error but no display
yes sir i save my file in htdocs .. .
here's screen shot ..

i save it xampp/htdocs/myfile.php
here's screen shot ..

i save it xampp/htdocs/myfile.php
Re: no error but no display
you do not run a php program like that for a server.
the server has to serve using http protocols, not file protocol which you are using.
that would be handled by windows.
try http://localhost/new.php
or http://127.0.0.1/new.php
never use the file protocol for a http site. the proper file protocol for internet is ftp. but of course in this case we are not concerned about that at all, we are merely with http.
the server has to serve using http protocols, not file protocol which you are using.
that would be handled by windows.
try http://localhost/new.php
or http://127.0.0.1/new.php
never use the file protocol for a http site. the proper file protocol for internet is ftp. but of course in this case we are not concerned about that at all, we are merely with http.
-
honoey_let004
- Forum Newbie
- Posts: 6
- Joined: Fri Mar 20, 2009 4:18 am
Re: no error but no display
Thank you so much! it works! 