Hi I keep getting Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in and dont know how to fix.

I have 1 table and need to display two colums awnser here is the code can any one olease point me in the right direction.

<?php

$result = mysql_query("SELECT contact_financial_invoiceamount-contact_financial_payment AS outstanding FROM contacts WHERE contact_id = ".$_GET['id']."");
while($row = mysql_fetch_row($result)

echo $row['outstanding'];

    ?>

There is an error in your query. Use $result = mysql_query("...") or die(mysql_error()); to find out more.

SELECT contact_financial_invoiceamount-contact_financial_payment AS outstanding

You must be missing comma between each field names which was bold. You should separate the query string and function. Here is readable format and less errors.

$sql = "SELECT contact_financial_invoice, amount-contact, financial_payment AS outstanding FROM contacts WHERE contact_id = ".$_GET['id'];
$result = mysql_query($sql);

What he pasted, appears to just be two long column names, which he is subtracting for the result ;)

In this line:

$result = mysql_query("SELECT contact_financial_invoiceamount-contact_financial_payment AS outstanding FROM contacts WHERE contact_id = ".$_GET['id']."");

I think you should write:

$result = mysql_query("SELECT contact_financial_invoiceamount-contact_financial_payment AS outstanding FROM contacts WHERE contact_id = '{$_GET['id']}'");

instead. Cause generally you are not allowed to use two double quotation marks together.

Member Avatar for jmichae3

while($row = mysql_fetch_row($result) is missing a )

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.