database.php problem

Reply

Join Date: Feb 2009
Posts: 9
Reputation: netviper is an unknown quantity at this point 
Solved Threads: 0
netviper netviper is offline Offline
Newbie Poster

database.php problem

 
0
  #1
Feb 19th, 2009
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
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 525
Reputation: Will Gresham is on a distinguished road 
Solved Threads: 85
Sponsor
Will Gresham's Avatar
Will Gresham Will Gresham is offline Offline
Posting Pro

Re: database.php problem

 
0
  #2
Feb 19th, 2009
Post the lines around line 101, it may be one of the preceding lines causing this problem.
AJAX is not a programming language, scripting language or any other sort of language.
It is acheived by using JavaScript http functions.
So, AJAX = JavaScript.
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 9
Reputation: netviper is an unknown quantity at this point 
Solved Threads: 0
netviper netviper is offline Offline
Newbie Poster

Re: database.php problem

 
0
  #3
Feb 19th, 2009
  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.
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 1,226
Reputation: kkeith29 has a spectacular aura about kkeith29 has a spectacular aura about kkeith29 has a spectacular aura about 
Solved Threads: 167
kkeith29's Avatar
kkeith29 kkeith29 is offline Offline
Nearly a Posting Virtuoso

Re: database.php problem

 
0
  #4
Feb 19th, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 9
Reputation: netviper is an unknown quantity at this point 
Solved Threads: 0
netviper netviper is offline Offline
Newbie Poster

Re: database.php problem

 
0
  #5
Feb 19th, 2009
  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.


  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

  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.
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 1,226
Reputation: kkeith29 has a spectacular aura about kkeith29 has a spectacular aura about kkeith29 has a spectacular aura about 
Solved Threads: 167
kkeith29's Avatar
kkeith29 kkeith29 is offline Offline
Nearly a Posting Virtuoso

Re: database.php problem

 
0
  #6
Feb 19th, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 9
Reputation: netviper is an unknown quantity at this point 
Solved Threads: 0
netviper netviper is offline Offline
Newbie Poster

Re: database.php problem

 
0
  #7
Feb 19th, 2009
I don't know where to find the error log. I am new to this. please advise.
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 1,226
Reputation: kkeith29 has a spectacular aura about kkeith29 has a spectacular aura about kkeith29 has a spectacular aura about 
Solved Threads: 167
kkeith29's Avatar
kkeith29 kkeith29 is offline Offline
Nearly a Posting Virtuoso

Re: database.php problem

 
0
  #8
Feb 19th, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 1,421
Reputation: cwarn23 has a spectacular aura about cwarn23 has a spectacular aura about 
Solved Threads: 132
cwarn23's Avatar
cwarn23 cwarn23 is offline Offline
Nearly a Posting Virtuoso

Re: database.php problem

 
0
  #9
Feb 20th, 2009
Originally Posted by netviper View Post
}



$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:
  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.
Try not to bump 10 year old threads as it can be really annoying.
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 1,226
Reputation: kkeith29 has a spectacular aura about kkeith29 has a spectacular aura about kkeith29 has a spectacular aura about 
Solved Threads: 167
kkeith29's Avatar
kkeith29 kkeith29 is offline Offline
Nearly a Posting Virtuoso

Re: database.php problem

 
0
  #10
Feb 20th, 2009
Originally Posted by cwarn23 View Post
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:
  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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC