PHP code IF

This code causes my page to be blank
The correct SQL statements and database connections are in place:

----------------------------------------------------

<?php if ($row_unpaid['Paid'] == "Paid") {
                    echo <td colspan="12" align="center" class="body_bold_black"><a name="paid" id="paid"></a>Invoice Database (paid)</td>;  } ?>

 <?php if ($row_unpaid['Paid'] == "Pending") {
                    echo <td colspan="12" align="center" class="body_bold_black"><a name="unpaid" id="unpaid"></a>Invoice Database (Unpaid)</td>; } ?>

----------------------------------------------------
doctorbillTechAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Julian HansenCommented:
Is it an error that is causing the problem or the fact that neither of those if statements are firing?
What happens when you dump the $row_unpaid variable like so
<?php 
echo '<pre>' . print_r($row_unpaid, true) . '</pre>';
if ($row_unpaid['Paid'] == "Paid") {
                    echo <td colspan="12" align="center" class="body_bold_black"><a name="paid" id="paid"></a>Invoice Database (paid)</td>;  } ?>

 <?php if ($row_unpaid['Paid'] == "Pending") {
                    echo <td colspan="12" align="center" class="body_bold_black"><a name="unpaid" id="unpaid"></a>Invoice Database (Unpaid)</td>; } ?>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
doctorbillTechAuthor Commented:
No error
The page is just blank
0
doctorbillTechAuthor Commented:
If I run your statement the page is still blank
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Ray PaseurCommented:
"The page is blank" is a symptom of a PHP error that occurred when error_reporting() was set to suppress error messages.  PHP failed, it had some information for you, but there was no way to get the information to you.  Here are some good settings for figuring out what is going wrong in your script:

<?php
error_reporting(E_ALL);
ini_set('display_errors', TRUE);

Open in new window


You might try adding those statements to the top of your PHP scripts.  You might look for an error_log file.  You can find its name by looking at the browser output of the phpinfo() function.
0
doctorbillTechAuthor Commented:
I get this:

Notice: Undefined variable: details in C:\xampp\htdocs\TickTock_int\invoiceDatabase_pending.php on line 470
0
doctorbillTechAuthor Commented:
Thanks Ray - this has sorted it for me
I did not have a variable correctly referenced
0
Dave BaldwinFixer of ProblemsCommented:
At the very least, the text for the 'echo' statements needs to be quoted  Since double quotes are part of the string, I used single quotes around the whole string.

<?php if ($row_unpaid['Paid'] == "Paid") {
                    echo '<td colspan="12" align="center" class="body_bold_black"><a name="paid" id="paid"></a>Invoice Database (paid)</td>';  } ?>

 <?php if ($row_unpaid['Paid'] == "Pending") {
                    echo '<td colspan="12" align="center" class="body_bold_black"><a name="unpaid" id="unpaid"></a>Invoice Database (Unpaid)</td>'; } ?>

Open in new window

0
doctorbillTechAuthor Commented:
This is now working:
------------------------------------------------------
$heading = 'Invoice Database (Unpaid)';
$paidheading = 'Invoice Database (paid)';


<td colspan="12" align="center" class="body_bold_black"><a name="unpaid" id="unpaid"></a>
 <?php if ($row_Unpaid['Paid'] == "Paid") {
                    echo $heading;  } ?>
               <?php if ($row_Unpaid['Paid'] == "Pending") {
                    echo $paidheading;  } ?></td>
0
Ray PaseurCommented:
On how to use quotes correctly in PHP:
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_12241-Quotation-Marks-in-PHP.html

Glad you've got it pointed in the right direction! :-)
0
doctorbillTechAuthor Commented:
thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.