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
Hibba
Forum Commoner
Posts: 58 Joined: Fri Oct 29, 2004 11:37 pm
Post
by Hibba » Sat Dec 11, 2004 8:01 pm
Alright, I have no clue where the problem is in the code. Can someone please help me out? I took the code out in snippets and could not find a problem...
Code: Select all
<?php
$question1 = file_get_contents('question1.html');
$question2 = file_get_contents('question2.html');
$question3 = file_get_contents('question3.html');
$question4 = file_get_contents('question4.html');
$question5 = file_get_contents('question5.html');
if(isset($_POST['submit'])) {
extract($_POST);
if (empty($budget)) {
if (!empty($how_many)) $currentquestion = $question2;
if (!empty($purchase_price AND $down_payment)) $currentquestion = $question3;
if (!empty($credit_history)) $currentquestion = $question4;
if (!empty($gross_income AND $month_debt)) $currentquestion = $question5;
$form = "<form name ="myform" method="post" action="".$_SERVER['PHP_SELF']."">"; //beginning of the form
$form .= $currentquestion;
if (!empty($how_many)) $form .= "<input type="hidden" name="how_many" value="".$how_many."">";
if (!empty($purchase_price AND $down_payment)) {
$form .= "<input type="hidden" name="purchase_price" value="".$purchase_price."">";
$form .= "<input type="hidden" name="down_payment" value="".$down_payment."">";
}
if (!empty($credit_history)) $form .= "<input type="hidden" name="credit_history" value="".$credit_history."">";
if (!empty($gross_income AND $month_debt)) {
$form .= "<input type="hidden" name="gross_income" value="".$gross_income."">";
$form .= "<input type="hidden" name="month_debt" value="".$month_debt."">";
}
$form .= "<input type="submit" value="Submit" name="submit">"; //submit button
$form .= "</form>"; //end of form
echo $form;
} else {
echo "here is the final data.<p><pre>";
print_r ($_POST);
echo "</pre>";
}
} else {
$currentquestion = $question1;
$form = "<form name ="myform" method="post" action="".$_SERVER['PHP_SELF']."">";
$form .= $currentquestion;
$form .= "<input type="submit" value="Submit" name="submit">";
$form .= "</form>";
echo $form;
}
?>
Last edited by
Hibba on Sun Dec 12, 2004 12:50 pm, edited 1 time in total.
rehfeld
Forum Regular
Posts: 741 Joined: Mon Oct 18, 2004 8:14 pm
Post
by rehfeld » Sat Dec 11, 2004 8:23 pm
why do you think there is a problem?
Hibba
Forum Commoner
Posts: 58 Joined: Fri Oct 29, 2004 11:37 pm
Post
by Hibba » Sat Dec 11, 2004 9:29 pm
because nothing is outputted to the screen... parsing error, right?
rehfeld
Forum Regular
Posts: 741 Joined: Mon Oct 18, 2004 8:14 pm
Post
by rehfeld » Sun Dec 12, 2004 9:00 pm
post the error.
Hibba
Forum Commoner
Posts: 58 Joined: Fri Oct 29, 2004 11:37 pm
Post
by Hibba » Sun Dec 12, 2004 10:32 pm
Well...I am not sure as to how to find the error. I just know that the code above does not work because it produces a blank page and from what I gather, that usually means a parsing error.
Newbie, sorry...
ol4pr0
Forum Regular
Posts: 926 Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador
Post
by ol4pr0 » Sun Dec 12, 2004 10:53 pm
you might wanna start with putting the following right before the if (isset($POST / or right after.
And see if that will return something
Hibba
Forum Commoner
Posts: 58 Joined: Fri Oct 29, 2004 11:37 pm
Post
by Hibba » Sun Dec 12, 2004 11:14 pm
Ok, placing that right before gives me an empty array. Which is right. If I place it after the main else, then it fails...
I really don't know what the problem is.
Hibba
Forum Commoner
Posts: 58 Joined: Fri Oct 29, 2004 11:37 pm
Post
by Hibba » Sun Dec 12, 2004 11:59 pm
Ok, I think I may have figured out the problem. In line 19, the AND does not appear to be the correct thing to put there. When I take it out, and only say if one variable is not empty, then it works. SO, what is the correct way to say "If both variables are not empty"
Thanks so much!
rehfeld
Forum Regular
Posts: 741 Joined: Mon Oct 18, 2004 8:14 pm
Post
by rehfeld » Mon Dec 13, 2004 12:10 am
you have error_reporting or display_errors turned OFF
you need to turn it/them on, otherwise you will never be able to see any errors.
this may be good for a live website,
but you can clearly see its terrible for development/debugging
this is a fatal error
Code: Select all
if (!empty($purchase_price AND $down_payment)) $currentquestion = $question3;
it should be
Code: Select all
if (!empty($purchase_price) AND !empty$down_payment)) $currentquestion = $question3;
fix all occurances of that nature, theres more than 1
who wrote this? they obviously did not even test it......
Hibba
Forum Commoner
Posts: 58 Joined: Fri Oct 29, 2004 11:37 pm
Post
by Hibba » Mon Dec 13, 2004 12:47 am
Ok, as far as turning errors on, I have no clue how to do that. I run the PHP on the local server on my powerbook.
Secondly, I wrote this. As far as testing it, I guess I don't know how to do that. I use BBedit [demo] to write the code, but as far as that, I don't know much, obviously...
Thanks for the help though!!
rehfeld
Forum Regular
Posts: 741 Joined: Mon Oct 18, 2004 8:14 pm
Post
by rehfeld » Mon Dec 13, 2004 12:57 am
oh my mistake, when you said
"I took the code out in snippets"
i thought you meant you got this code from the snippets forum lol.
i thought someone else had posted this for others to use without even testing it to see if it worked...
sorry for not paying attention
locate your php.ini file
default error reporting should look like this
error_reporting = E_ALL & ~E_NOTICE
and
display_errors = On