Supplied Argument Is Not a Valid MySQL Result Resource

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource

Change $result = @mysql_query ($query);

with

$result = mysql_query ($query) or die(mysql_error());

and see if you have any errors.

EDIT:

You missed a comma after oc.price and before prd.products_id. Change your query like this:

$query = "SELECT us.users_id, us.users_first_name, us.users_surname, us.users_business, 
ord.order_id, ord.users_id, ord.total, ord.order_date,
oc.oc_id, oc.order_id, oc.products_id, oc.quantity, oc.price/*here*/,/**/
prd.products_id, prd.products_name, prd.price
FROM users AS us, orders AS ord, order_contents AS oc, products AS prd
WHERE ord.order_id=$id
AND us.users_id = ord.users_id
AND ord.order_id = oc.order_id
AND oc.products_id = prd.products_id
";

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL Result in line 40

This error means your query failed. mysql_query() returns false if an error occurred, you are then passing false to mysql_fetch_array() which is triggering the error message.

Your query could be failing due to a missing/wrong table or field. To see the detailed error, print out the result of mysql_error().


The mysql_* library is deprecated. It is recommended to upgrade to MySQLi or PDO.

Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in ,

You are getting your first error because you don't have a database connection open within your function. The second error is a follow up error and is caused by the same problem. In order to solve this you can either pass the connection to your function as a parameter or, create a new connection inside of the function. (As stated in the comments by 'Jay Blanchard' )

supplied argument is not a valid MySQL result resource

The SQL query has not finished correctly. You most likely uploaded the script, but have either not uploaded the database, or have wrong database credentials.

Hint You can get very good and descriptive error messages when you put the following code after a failing mysql_query statement:

if (mysql_error()) {
die(mysql_error());
}

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result

write like this:

$sql_select="select route from $client_id WHERE net_id = ".$rownum."";
$queryRes = mysql_query($sql_select);
print $sql_select;
print mysql_error();
$i=1;
while($rows=mysql_fetch_assoc($queryRes))

You need to provide #Resource returned from mysql_query() function to mysql_fetch_assoc().

Note: Mysql_* are deprecated from PHP5.3. Hence should be avoided.

mysql_fetch_assoc(): 6 is not a valid MySQL result resource

Make sure to add checks when making your connection as well as after the query

    $server = '127.0.0.1';
$username = 'root';
$password = '';
$database = 'test';

mysql_connect($server, $username, $password) or die(mysql_error());
mysql_select_db($database) or die(mysql_error());

$TableName = "opportunities";
$Opportunities = array();
$SQLString = "SELECT opportunity_ID, company, city, " .
"start_date, end_date, position, description" . " FROM $TableName;";
$QueryResult = mysql_query($SQLString);

if(mysql_error()) {
die(mysql_error();
}

if($QueryResult) {

while($Row = mysql_fetch_assoc($QueryResult))
{
$Opportunities[] = $Row;
}
mysql_free_result($QueryResult);
}

mysql_close();

Also, you were freeing the result $QueryResult inside the loop, so the next iteration would have no resource to grab data from.



Related Topics



Leave a reply



Submit