Re: Help with nested if statements, is this possible?
| From: | martinahingis | Date: | Mon, 01 Apr 2002 12:24:11 +0000 |
| Subject: | Re: Help with nested if statements, is this possible? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-90938@lists.php.net to get a copy of this message | ||
if ($payment_status = "Completed")
if you do this your if statement is invalid
You should do
if ($payment_status == "Completed")
I mean you should use double '=' inorder to say 'equals'.
"Jim Hankins" <jhankins@hankinsbay.com> wrote in message
news:20020401030805.26758.qmail@pb1.pair.com...
> Here is a portion of a work in progress, I tested by sending the script
with
> a payment status of incomplete yet it still executed other portions of the
> code. Should it not have jumped out. Or is my nested if invalid for some
> reason?
>
> if ($payment_status = "Completed")
> {
> echo "1st if is passed<br>";
> // check that txn_id has not been previously processed
>
> $db_conn = mysql_connect("localhost:/var/lib/mysql/mysql.sock", "apache",
> "xxx");
> mysql_select_db("telnetlabs", $db_conn);
> $query = "select pp_txn_id from orders "
> ."where pp_txn_id ='.$txn_id.' ";
> $result = mysql_query($query, $db_conn);
> echo "This is the result of 1st query<br>";
> echo $result;
> echo "<br>";
> $num_results = mysql_num_rows($result);
> echo $num_results;
>
> if ($num_results)
> {
> }
> else {
>
> echo "2nd if is passed<br>";
> $query = "select cust_email from customers "
> ."where cust_email = '$payer_mail' ";
> $result = mysql_query($query, $db_conn);
> $num_results = mysql_num_rows($result);
>
> if ($num_results)
> {
> }
> else
> {
> echo "3rd if is passed<br>";
> $item_name=addslashes($item_name);
> $receiver_email=addslashes($receiver_email);
> $item_number=addslashes($item_number);
> $invoice=addslashes($invoice);
> $payment_status=addslashes($payment_status);
> $payment_gross=addslashes($payment_gross);
> $txn_id=addslashes($txn_id);
> $payer_email=addslashes($payer_email);
> $payer_status=addslashes($payer_status);
> $first_name=addslashes($first_name);
> $last_name=addslashes($last_name);
> $address_status=addslashes($address_status);
> $address_street=addslashes($address_street);
> $address_city=addslashes($address_city);
> $address_state=addslashes($address_state);
> $address_country=addslashes($address_country);
> echo $first_name;
> echo $last_name;
> echo $address_street;
> echo $address_city;
> echo $address_state;
> echo $address_status;
> echo $address_zip;
> echo $payer_status;
> echo $item_name;
> echo $receiver_email;
> echo $item_number;
> echo $invoice;
> echo $payment_status;
> echo $address_country;
>
> //$query = "insert into customers values ('"null"',
> '".$first_name."',
> '".$last_name."', '".$address_street."',
> '".$address_city."' ,
> '".$address_state."', '".$address_status."',
> '".$payer_email."' ,
> '".$payer_status."', '".$payer_email."' ,
> '".$txn_id."', '"1"')";
> // check that receiver_email is an email address in your PayPal account
> // check that payer_email doesn't already exist in customer database
> // if exist, increment customer.balanace by 1
> // if not exist, create user and increment balance by 1
> // then send schedule email with userid and password
> // process payment
> // first stab does none of the processes above, just emails the customer
and
> us for testing
> mail ("jhankins@hankinsbay.com", "order info", trim($mailcontent),
> "From:
> sales@telnetlabs.com", "-fsales@telnetlabs.com");
> mail ($payer_email, "Your Order", $custconfirmation, "From:
> sales@telnetlabs.com", "-fsales@telnetlabs.com");
> }
> }
> }
> ?>
>
>