Try rewriting your query. It looks to me that you probably have an
error in your SQL statement and it only seems fine because you appended
the @ to the beginning of the mysql_query() function.
  I would suggest using a join statement.

If(!$result = mysql_query("SELECT orders.orderid, orders.amount,, FROM orders RIGHT JOIN customers on
orders.customerid = customers.customerid WHERE = 'Don
Hansen'")) {
  echo(mysql_error());  //I would take this out after you are done
} else {
  while ($row = mysql_fetch_array($result)) {
        $zorderid = $row['orders.orderid'];
        $zamt = $row['orders.amount'];
        echo(str_pad($zorderid,4,' ').str_pad($zamt,6, '  ').'<br>');
-----Original Message-----
Sent: Tuesday, October 28, 2003 9:20 AM
Subject: show data from 2 tables

I am attempting to pull data from 2 tables.  My SELECT statement seems
ok.  But the next line: while ... etc. is giving me an error of
"Supplied argument is not a valid MySQL result resource.".  But this is
the way I usually show my data and it works fine when only 1 table is
involved.  Is there a different way of showing your data when pulling
data from more than one table?

$result = @mysql_query('SELECT orders.orderid, orders.amount,
        from customers, orders WHERE = "Don Hansen" and
        customers.customerid = orders.customerid');

while ( $row = mysql_fetch_array($result) )
        $zorderid = $row['orders.orderid'];
        $zamt = $row['orders.amount'];
        echo (str_pad($zorderid,4,' ') .  str_pad($zamt,6, '  ') .


PHP Database Mailing List (
To unsubscribe, visit:

Reply via email to