no error but no display

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
honoey_let004
Forum Newbie
Posts: 6
Joined: Fri Mar 20, 2009 4:18 am

no error but no display

Post 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
Paul Arnold
Forum Contributor
Posts: 141
Joined: Fri Jun 13, 2008 10:09 am
Location: Newcastle Upon Tyne

Re: no error but no display

Post 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.
honoey_let004
Forum Newbie
Posts: 6
Joined: Fri Mar 20, 2009 4:18 am

Re: no error but no display

Post 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 . . . :cry:

", $quantity, 'widget(s) at a cost of $', $price. ' each. With tax, the total comes to $', $total, '.'; ?>

pls help . .. .
User avatar
Inkyskin
Forum Contributor
Posts: 282
Joined: Mon Nov 19, 2007 10:15 am
Location: UK

Re: no error but no display

Post by Inkyskin »

Your error reporting might not be set to a high enough level, try putting this at the top of your document:

Code: Select all

 
<?php
error_reporting(E_ALL);
?>
 
Also, it's much easier to read the code, and therefore diagnose any issues, if you wrap it in code tags :)
honoey_let004
Forum Newbie
Posts: 6
Joined: Fri Mar 20, 2009 4:18 am

Re: no error but no display

Post 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 . ..
Image

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.
User avatar
Inkyskin
Forum Contributor
Posts: 282
Joined: Mon Nov 19, 2007 10:15 am
Location: UK

Re: no error but no display

Post 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

Code: Select all

 tags.
User avatar
Inkyskin
Forum Contributor
Posts: 282
Joined: Mon Nov 19, 2007 10:15 am
Location: UK

Re: no error but no display

Post 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.
honoey_let004
Forum Newbie
Posts: 6
Joined: Fri Mar 20, 2009 4:18 am

Re: no error but no display

Post by honoey_let004 »

I am currently using XAMPP i've also test myPhpAdmin and its working also the Apache . . . :cry:
User avatar
Inkyskin
Forum Contributor
Posts: 282
Joined: Mon Nov 19, 2007 10:15 am
Location: UK

Re: no error but no display

Post 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
honoey_let004
Forum Newbie
Posts: 6
Joined: Fri Mar 20, 2009 4:18 am

Re: no error but no display

Post by honoey_let004 »

yes sir i save my file in htdocs .. .

here's screen shot ..

Image

i save it xampp/htdocs/myfile.php
User avatar
php_east
Forum Contributor
Posts: 453
Joined: Sun Feb 22, 2009 1:31 pm
Location: Far Far East.

Re: no error but no display

Post 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.
honoey_let004
Forum Newbie
Posts: 6
Joined: Fri Mar 20, 2009 4:18 am

Re: no error but no display

Post by honoey_let004 »

Thank you so much! it works! :D
Post Reply