Page 1 of 1

What's the problem? [Still need help!]

Posted: Sat Dec 11, 2004 8:01 pm
by Hibba
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;
}
?>

Posted: Sat Dec 11, 2004 8:23 pm
by rehfeld
why do you think there is a problem?

Posted: Sat Dec 11, 2004 9:29 pm
by Hibba
because nothing is outputted to the screen... parsing error, right?

Posted: Sun Dec 12, 2004 9:00 pm
by rehfeld
post the error.

Posted: Sun Dec 12, 2004 10:32 pm
by Hibba
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...

Posted: Sun Dec 12, 2004 10:53 pm
by ol4pr0
you might wanna start with putting the following right before the if (isset($POST / or right after.

Code: Select all

print_r($_POST);
And see if that will return something

Posted: Sun Dec 12, 2004 11:14 pm
by Hibba
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.

Posted: Sun Dec 12, 2004 11:59 pm
by Hibba
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!

Posted: Mon Dec 13, 2004 12:10 am
by rehfeld
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......

Posted: Mon Dec 13, 2004 12:47 am
by Hibba
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!!

Posted: Mon Dec 13, 2004 12:57 am
by rehfeld
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