943,027 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 1681
  • PHP RSS
You are currently viewing page 1 of this multi-page discussion thread
Feb 19th, 2009
0

database.php problem

Expand Post »
Guys, I need some help. I installed a mod on oscmax for updated product attributes. It works fine, BUT now the products in my site won't pull up. Everything looks fine on the site until you actually click on a product, then you get.

Warning:mysql_fetch_array(): supplied argument is not a valid MySQL results resource in /home/sportsti/public_html/includes/functions/database.php on line 101

FYI, line 101 is " return $result;"

I didn't make any changes to database.php

Please help. I don't know what I did wrong.

the site is www.sportstickies.com

Thanks
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
netviper is offline Offline
9 posts
since Feb 2009
Feb 19th, 2009
0

Re: database.php problem

Post the lines around line 101, it may be one of the preceding lines causing this problem.
Reputation Points: 96
Solved Threads: 124
Master Poster
Will Gresham is offline Offline
728 posts
since May 2008
Feb 19th, 2009
0

Re: database.php problem

php Syntax (Toggle Plain Text)
  1. }
  2.  
  3.  
  4.  
  5. $result = mysql_query($query, $$link) or tep_db_error($query, mysql_errno(), mysql_error());
  6.  
  7.  
  8.  
  9. if (defined('STORE_DB_TRANSACTIONS') && (STORE_DB_TRANSACTIONS == 'true')) {
  10.  
  11. if (mysql_error()) $logger->write(mysql_error(), 'ERROR');
  12.  
  13. }
  14.  
  15.  
  16.  
  17. return $result;
  18.  
  19. }
  20.  
  21.  
  22.  
  23. function tep_db_perform($table, $data, $action = 'insert', $parameters = '', $link = 'db_link') {
  24.  
  25. reset($data);
  26.  
  27. if ($action == 'insert') {
  28.  
  29. $query = 'insert into ' . $table . ' (';
  30.  
  31. while (list($columns, ) = each($data)) {
  32.  
  33. $query .= $columns . ', ';
  34.  
  35. }
  36.  
  37. $query = substr($query, 0, -2) . ') values (';


Thank you for helping.
Last edited by peter_budo; Feb 21st, 2009 at 5:01 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
netviper is offline Offline
9 posts
since Feb 2009
Feb 19th, 2009
0

Re: database.php problem

an invalid resource is usually caused by a bad sql query. this doesn't mean something is wrong with the database page. the problem lies in the page that calls that function on the database page. can you post the code for product_info.php
Last edited by kkeith29; Feb 19th, 2009 at 11:19 pm.
Reputation Points: 235
Solved Threads: 193
Nearly a Posting Virtuoso
kkeith29 is offline Offline
1,315 posts
since Jun 2007
Feb 19th, 2009
0

Re: database.php problem

php Syntax (Toggle Plain Text)
  1. <?php
  2.  
  3. /*
  4.  
  5. $Id: product_info.php 3 2006-05-27 04:59:07Z user $
  6.  
  7.  
  8.  
  9.   osCMax Power E-Commerce
  10.  
  11.   [url]http://oscdox.com[/url]
  12.  
  13.  
  14.  
  15.   Copyright 2006 osCMax
  16.  
  17.  
  18.  
  19.   Released under the GNU General Public License
  20.  
  21. */
  22.  
  23.  
  24.  
  25. // Most of this file is changed or moved to BTS - Basic Template System - format.
  26.  
  27. // For adding in contribution or modification - parts of this file has been moved to: catalog\templates\fallback\contents\<filename>.tpl.php as a default (sub 'fallback' with your current template to see if there is a template specife change).
  28.  
  29. // catalog\templates\fallback\contents\<filename>.tpl.php as a default (sub 'fallback' with your current template to see if there is a template specife change).
  30.  
  31. // (Sub 'fallback' with your current template to see if there is a template specific file.)
  32.  
  33.  
  34.  
  35. require('includes/application_top.php');
  36.  
  37.  
  38.  
  39. // LINE ADDED: MOD - Added for Dynamic MoPics v3.000
  40.  
  41. require(DIR_WS_FUNCTIONS . 'dynamic_mopics.php');
  42.  
  43. require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_PRODUCT_INFO);
  44.  
  45.  
  46.  
  47. // BOE: Attribute Sort with Clone Tool
  48. $products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pa.options_id = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "' order by pa.attribute_sort");
  49. // EOE: Attribute Sort with Clone Tool
  50.  
  51.  
  52. $product_check = tep_db_fetch_array($product_check_query);
  53.  
  54.  
  55.  
  56. $content = CONTENT_PRODUCT_INFO;
  57.  
  58. $javascript = 'popup_window.js';
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66. include (bts_select('main', $content_template)); // BTSv1.5
  67.  
  68.  
  69.  
  70. require(DIR_WS_INCLUDES . 'application_bottom.php');
  71.  
  72. ?>


I did have to modify the code on this page.


php Syntax (Toggle Plain Text)
  1. // BOE: Attribute Sort with Clone Tool
  2. $products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pa.options_id = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "' order by pa.attribute_sort");
  3. // EOE: Attribute Sort with Clone Tool


REPLACED

php Syntax (Toggle Plain Text)
  1. $products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pa.options_id = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "'");
Last edited by peter_budo; Feb 21st, 2009 at 5:02 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
netviper is offline Offline
9 posts
since Feb 2009
Feb 19th, 2009
0

Re: database.php problem

does attribute_sort column exist in the TABLE_PRODUCTS_ATTRIBUTES table? that is the only thing added so something is wrong there.

also, check the error log for the sql error. post the error once you find it.
Last edited by kkeith29; Feb 19th, 2009 at 11:34 pm.
Reputation Points: 235
Solved Threads: 193
Nearly a Posting Virtuoso
kkeith29 is offline Offline
1,315 posts
since Jun 2007
Feb 19th, 2009
0

Re: database.php problem

I don't know where to find the error log. I am new to this. please advise.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
netviper is offline Offline
9 posts
since Feb 2009
Feb 19th, 2009
0

Re: database.php problem

its probably a config setting when you install the software. check your config files. also look for folders and files that say log or error, ect.

also, it might be in the logging class. can you find this log class? its referenced in your first post. it logs the error somehow.
Reputation Points: 235
Solved Threads: 193
Nearly a Posting Virtuoso
kkeith29 is offline Offline
1,315 posts
since Jun 2007
Feb 20th, 2009
0

Re: database.php problem

Click to Expand / Collapse  Quote originally posted by netviper ...
}



$result = mysql_query($query, $$link) or tep_db_error($query, mysql_errno(), mysql_error());



if (defined('STORE_DB_TRANSACTIONS') && (STORE_DB_TRANSACTIONS == 'true')) {

if (mysql_error()) $logger->write(mysql_error(), 'ERROR');

}



return $result;

}



function tep_db_perform($table, $data, $action = 'insert', $parameters = '', $link = 'db_link') {

reset($data);

if ($action == 'insert') {

$query = 'insert into ' . $table . ' (';

while (list($columns, ) = each($data)) {

$query .= $columns . ', ';

}

$query = substr($query, 0, -2) . ') values (';


Thank you for helping.
I noticed a few errors in that script. One is the sql linker will need the extra dollar sign removing and is shown as follows:
php Syntax (Toggle Plain Text)
  1. $result = mysql_query($query, $$link) or tep_db_error($query, mysql_errno(), mysql_error());
  2.  
  3. //above may need replacing with below:
  4.  
  5. $result = mysql_query($query, $link) or tep_db_error($query, mysql_errno(), mysql_error());
Also the line return $result; may also cause an error if it is not within a box. By saying a box, I meen a function, a external to internal command call (eg. include() ) or oop object. If the return is not in a box then from my experience, it will just return the $result status and prevent further executing of the php file and may even cause an extra error during the process.
But that $$link variable should really be changed and hope it helps.
Sponsor
Featured Poster
Reputation Points: 410
Solved Threads: 258
Occupation: Genius
cwarn23 is offline Offline
3,003 posts
since Sep 2007
Feb 20th, 2009
0

Re: database.php problem

Click to Expand / Collapse  Quote originally posted by cwarn23 ...
I noticed a few errors in that script. One is the sql linker will need the extra dollar sign removing and is shown as follows:
php Syntax (Toggle Plain Text)
  1. $result = mysql_query($query, $$link) or tep_db_error($query, mysql_errno(), mysql_error());
  2.  
  3. //above may need replacing with below:
  4.  
  5. $result = mysql_query($query, $link) or tep_db_error($query, mysql_errno(), mysql_error());
Also the line return $result; may also cause an error if it is not within a box. By saying a box, I meen a function, a external to internal command call (eg. include() ) or oop object. If the return is not in a box then from my experience, it will just return the $result status and prevent further executing of the php file and may even cause an extra error during the process.
But that $$link variable should really be changed and hope it helps.
$$link is valid. you can use a dynamic name for a variable.
Reputation Points: 235
Solved Threads: 193
Nearly a Posting Virtuoso
kkeith29 is offline Offline
1,315 posts
since Jun 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: single quotes(') problem in inserting data into database
Next Thread in PHP Forum Timeline: help form mail script. line 17





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC