bastet
bastet

Reputation: 213

My dreamweaver doesn't work right

I'm a true beginner in php. I installed wampserver and adobe dreamweaver. I tried to write some codes to understand php, but it doesn't work right. My code is here;

<HTML>
<HEAD>
<TITLE>function testing</TITLE>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-9">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1254">
</HEAD>
<BODY>
<?php
function sum1 ($num1, $num2) {$result = $num1 + $num2; return $result;}
function sub1 ($num1, $num2) {$result = $num1 - $num2; return $result;}
$num1 = 12; $num2 = 5;
print sum1($num1, $num2); print ("<br>"); print sub1($num1, $num2); print ("<br>");
?>
</BODY>
</HTML>

I tried to run and i just see that in my browser;

"); print sub1($num1, $num2); print (" "); ?>

what do you suggest me to fix this problem? Thanks in advance..

Upvotes: 1

Views: 886

Answers (5)

eHussain
eHussain

Reputation: 3367

It seems that you have defined function with name of sum1 an sub1 and calling it via sum and sub respectively.

So, your browser is not displaying output but its showing error..

Try out following.

<HTML>
<HEAD>
<TITLE>function testing</TITLE>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-9">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1254">
</HEAD>
<BODY>
<?php
function sum1 ($num1, $num2) {$result = $num1 + $num2; return $result;}
function sub1 ($num1, $num2) {$result = $num1 - $num2; return $result;}
$num1 = 12; $num2 = 5;
print sum($num1, $num2); print ("<br>"); print sub($num1, $num2); print ("<br>");
?>
</BODY>
</HTML>

Thanks!

Hussain

Upvotes: 0

OneOfOne
OneOfOne

Reputation: 99324

It looks like your file isn't being handled as a php file, check the server logs and make sure you have php enabled in your apache.

And as a side note, oh dear god the uglyness of uppercase tag names is killing my eyes, and why in the world are you using 2 content-type tags?

Please check this and this to produce valid (x)html code from dreamweaver.

Upvotes: 0

selladurai
selladurai

Reputation: 6789

if you want to start from the scratch follow this site: http://www.tizag.com/phpT/

it is simply great, i have learnt my basics from here .

For your instant solution i have something for you:

1.install wamp from here:http://www.wampserver.com/ 2.install it 3.a tray icon will appear 4.right click it start the server 5.open a notepad ,type your code ,save as "myfirsttry.php" (with qoutes) 6.copy this file and paste it in wamp/www folder 7.again go to the tray icon launch the browser from there

Upvotes: 1

MatTheCat
MatTheCat

Reputation: 18731

Why don't you use parenthesis aroud function calls? And function names are differents.

Anyway it's recommended to use echo which allow to forget parenthesis among others.

Upvotes: 0

Falle1234
Falle1234

Reputation: 5063

It seems that your server doesn't recognize the > of print("<br>") to be the closing part of the php-tag. This is due to the server not knowing how to handle your php-tag.

Hope this helps you

Upvotes: 0

Related Questions