Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Warning: Mysql_fetch_array(): Supplied Argument Is Not A Valid Mysql Result Resource In Includes/functions/database.php On Line 99?


akent64

Recommended Posts

After including the sort order contribution for product attributes I seem to have the following error at the top of a page when I click on a product:

 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /var/www/html/oscommerce/includes/functions/database.php on line 99

 

This error means that the product cannot found for some reason even though it is there?!

 

Any help would be greatly appreciated

 

Thanks

 

Andy

Edited by akent64
Link to comment
Share on other sites

After including the sort order contribution for product attributes I seem to have the following error at the top of a page when I click on a product:

 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /var/www/html/oscommerce/includes/functions/database.php on line 99

 

This error means that the product cannot found for some reason even though it is there?!

 

Any help would be greatly appreciated

 

Thanks

 

Andy

 

What code is found in and around /var/www/html/oscommerce/includes/functions/database.php on line 99?

Do, or do not. There is no try.

 

Order Editor 5.0.6 "Ultra Violet" is now available!

For support or to post comments, suggestions, etc, please visit the Order Editor support thread.

Link to comment
Share on other sites

return mysql_fetch_array($db_query, MYSQL_ASSOC);

 

Well, the problem isn't in database.php. What file is it that you trying to view when you get the error?

Do, or do not. There is no try.

 

Order Editor 5.0.6 "Ultra Violet" is now available!

For support or to post comments, suggestions, etc, please visit the Order Editor support thread.

Link to comment
Share on other sites

Well, the problem isn't in database.php. What file is it that you trying to view when you get the error?

 

I'm just trying to view a product on my database, when I click on the product, altohugh the picture is there for the product, once I click on it is says that no product has been found

Link to comment
Share on other sites

  • 2 weeks later...
I'm just trying to view a product on my database, when I click on the product, altohugh the picture is there for the product, once I click on it is says that no product has been found

 

What's in the address bar of your web browser when you see the error?

Do, or do not. There is no try.

 

Order Editor 5.0.6 "Ultra Violet" is now available!

For support or to post comments, suggestions, etc, please visit the Order Editor support thread.

Link to comment
Share on other sites

Hi I am getting exactly the same error.

However it shows only at catalog dir, checkout, login etc...

When i view products, descriptions etc. the error disappeares .

 

hmm what could be the problem? :huh:

 

Are you using the sort order contribution for product attributes?

Do, or do not. There is no try.

 

Order Editor 5.0.6 "Ultra Violet" is now available!

For support or to post comments, suggestions, etc, please visit the Order Editor support thread.

Link to comment
Share on other sites

  • 2 weeks later...

I am having the same problem. Heres what happened i was using sort order contribution and i didnt like it so i removed the extra column it added in my mysql database and deleted the added in lines on the php files and i get that msg. How do i fix this.

Edited by splitbux
Link to comment
Share on other sites

  • 1 month later...

I have the same after installing QT Pro4.0.1.2

The address in the bar is product_info so something is wrong over there, but what to look for?

Edited by ttime
Link to comment
Share on other sites

  • 4 months later...

I receive the same fatal error when a customer adds a product to their shopping cart, clicks continue and enters the Checkout_shipping Page.....same line as well and also in my includes/functions/database.php

 

Anyone have any ideas on this yet???

Link to comment
Share on other sites

  • 6 months later...

Here is help for the following error:

 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /var/www/html/oscommerce/includes/functions/database.php on line 99

 

Line 98-100 of my database.php file contained:

 

		  function tep_db_fetch_array($db_query) {
		return mysql_fetch_array($db_query, MYSQL_ASSOC);
	  }

Clearly, somewhere in my code I had a call to tep_db_fetch_array, in which I was passing an invalid resource. The proper way to call tep_deb_fetch_array is to first prepare a select statement using tep_db_query, as shown below:

 

		$my_select_statement = 'Select * from ' . TABLE_CATEGORIES;
	$my_query = tep_db_query($my_select_statement);
	while ($my_result_row = tep_db_fetch_array($my_query)) {
		$my_cat_id = $my_result_row['categories_id'];
		....
	}

The function tep_db_query returns an resource of type 'mysql result'. If $my_query had been an invalid resource (eg not defined, or null, containing a string or numeric value, or containing anything at all other than a properly formed 'mysql result' resource), then it would have caused warning message I saw.

 

One way of testing your code is to call mysql_query directly, bypassing all the osc wrappers, like so:

 

		$my_select_statement = 'Select * from ' . TABLE_CATEGORIES;
	$qr1 = mysql_query ($my_select_statement) 
			or die ("Query failed: " . mysql_error() . " Actual query: " . $my_select_statement);

In my case, I got this warning message after making a mistake in installing Linda McGrath's very nice addon Attributes Sorter and Copier (http://www.oscommerce.com/community/contributions,772) version 5.1b. It concerned some tricky merging of code in the file catalog\admin\categories.php, tricky because I had already edited that section of code with other addons (Additional Images and New Attribute Manager). I had the line:

 

		while ($new_images = tep_db_fetch_array($images_product)) {

But $images_product was undefined because I had overwritten the code that defined it.

 

The tricky section of code in file catalog\admin\categories.php started with:

 

	  default:
	if ($rows > 0) {
	  if (isset($cInfo) && is_object($cInfo)) {

and ended with:

 

		} else { // create category/product info
	  $heading[] = array('text' => '<b>' . EMPTY_CATEGORY . '</b>');

	  $contents[] = array('text' => TEXT_NO_CHILD_CATEGORIES_OR_PRODUCTS);
	}
	break;
}

By reinstalling this section of code from my backup, and then more carefully installing the Attributes Sorter and Copier addon, I was able to fix the problem.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...