Page 1 of 1
no error but no display
Posted: Fri Mar 20, 2009 4:26 am
by honoey_let004
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
Re: no error but no display
Posted: Fri Mar 20, 2009 4:36 am
by Paul Arnold
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.
Re: no error but no display
Posted: Fri Mar 20, 2009 6:23 pm
by honoey_let004
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 . .. .
Re: no error but no display
Posted: Fri Mar 20, 2009 6:26 pm
by Inkyskin
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

Re: no error but no display
Posted: Fri Mar 20, 2009 6:41 pm
by honoey_let004
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
Re: no error but no display
Posted: Fri Mar 20, 2009 6:48 pm
by Inkyskin
Your code appears quite badly formatted:
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>";
And again, PLEASE wrap your code in
Re: no error but no display
Posted: Fri Mar 20, 2009 7:07 pm
by Inkyskin
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.
Re: no error but no display
Posted: Fri Mar 20, 2009 7:34 pm
by honoey_let004
I am currently using XAMPP i've also test myPhpAdmin and its working also the Apache . . .

Re: no error but no display
Posted: Fri Mar 20, 2009 7:37 pm
by Inkyskin
you need to place your files in the htdocs directory of xampp, make sure its running, and then type
http://localhost/myfile.php
Re: no error but no display
Posted: Fri Mar 20, 2009 8:05 pm
by honoey_let004
yes sir i save my file in htdocs .. .
here's screen shot ..
i save it xampp/htdocs/myfile.php
Re: no error but no display
Posted: Fri Mar 20, 2009 8:23 pm
by php_east
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.
Re: no error but no display
Posted: Fri Mar 20, 2009 10:02 pm
by honoey_let004
Thank you so much! it works!
