Jump to content

[SOLVED] mysql_num_rows(): supplied argument is not a valid MySQL result....


davey_b_

Recommended Posts

Why am I getting this???

 

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /var/www/.../vieworder.php on line 130

 

<?php
$sql=" SELECT o.*, u.user_name, u.email, od.artist_id,cm.nexchange_price
	 FROM ".$tableprefix."orders o,".$tableprefix."currency_master cm
	INNER JOIN ".$tableprefix."users u ON o.user_id = u.user_id
	INNER JOIN ".$tableprefix."order_details od ON o.order_id = od.order_id
	WHERE o.order_id = ".GetSQLValueString($orderid,"text")."
	 AND o.vorder_currency = cm.vcurrency_code
	 AND o.user_id = ".$_SESSION["sess_userid"].
	 $qryopt . " ORDER BY o.order_date DESC ";

$result = mysql_query($sql);

if(mysql_num_rows($result) !=0)
{
$prow = mysql_fetch_array($result);
$ordernumber = $prow["order_id"];
$username = $prow["user_name"];
$ordertotal = $prow["order_total_price"];
$orderdate = $prow["order_date"];
$orderdate = dateFormat($orderdate,"Y-m-d","d-M-Y");
$userid = $prow["user_id"];
$exchange_price = $prow["nexchange_price"];

}

else
{
$order_flag = 1;
}

 

Being a bit of a n00b!

 

Query: SELECT o.*, u.user_name, u.email, od.artist_id,cm.nexchange_price FROM tug_orders o,tug_currency_master cm INNER JOIN tug_users u ON o.user_id = u.user_id INNER JOIN tug_order_details od ON o.order_id = od.order_id WHERE o.order_id = '5' AND o.vorder_currency = cm.vcurrency_code AND o.user_id = 1 ORDER BY o.order_date DESC

 

Error: (1054) Unknown column 'o.user_id' in 'on clause'

Tsk, tsk... don't mix comma and JOIN!  Let me guess, you're using MySQL 5?

 

This will work, but it's band-aid:

SELECT o.*, u.user_name, u.email, od.artist_id,cm.nexchange_price 
FROM ( tug_orders o,tug_currency_master cm ) 
INNER JOIN tug_users u ON o.user_id = u.user_id 
INNER JOIN tug_order_details od ON o.order_id = od.order_id 
WHERE o.order_id = '5' AND o.vorder_currency = cm.vcurrency_code AND o.user_id = 1 
ORDER BY o.order_date DESC

 

This is much better:

SELECT o.*, u.user_name, u.email, od.artist_id,cm.nexchange_price 
FROM tug_orders o 
INNER JOIN tug_currency_master cm ON ( o.vorder_currency = cm.vcurrency_code ) 
INNER JOIN tug_users u ON ( o.user_id = u.user_id ) 
INNER JOIN tug_order_details od ON ( o.order_id = od.order_id ) 
WHERE o.order_id = '5' AND o.user_id = 1 
ORDER BY o.order_date DESC

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.