![]() |
bought a book to help me learn php. i type the code directly from the book and save it in the root directory on my computer, but then when i type in the address in my browser, the page will load but not work like it is supposed to.
here is the code for both pages. (its just a simple calculation script). calculate.php: Code:
<? Code:
<HTML> thanks in advance. |
Do you have PHP installed???
|
yes, i installed phptriad which installs php, mysql, and apache. (it also configures everything). and yes i had apache running also.
|
Oh, ok, well, that's the only reason that I can think of. Sorry!
|
try to comment out this part of your script like this:
//if (($_POST[val1] == "") || ($_POST[calc] =="")) { //header("Location: //http://127.0.0.1/calculate_form.html"); //exit; //} then run it and see what happens, i think something is wrong in that piece of code there and it's just reloading calculate_form.html instead of executing the rest of the script |
ok that did it for that, but when the calculate.php loads the following is displayed:
Code:
The result of the calculation is: |
just as a test, try to echo your other variables like you did with $result, just to see if they are getting any data stored in them, i don't think they are from what it's doing
|
yea... generally a decent idea for the php code I've written is to have a $debug variable at the top of the file that you can toggle (1/0) depending on if you want to print/echo a bunch of other variables... so for example, my code is littered with statements like this:
if ($debug) echo ("var: " . $var . "\n"); you may throw in some formatting to make it look better and more readable, like i did above.... hope this helps, and in the future, documentation always helps debugging too. ;) Sorry for the lecture, but hope you get things working!!! :D Have fun, cappaberra |
ok it turns out there wasn't anything wrong with the code, but with my installation of php(i think).
i had installed phptriad which someone recommended cause it setup everything for you (php, apache, mysql), then someone at another forum told me to install phpdev so i did that and moved my files and now everything works. thanks again for everyones support. |
Ha, knew it was an installation problem ;). Glad you got it working!
|
All times are GMT +1. The time now is 08:02 PM. |
Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.