/    Sign up×
Community /Pin to ProfileBookmark

Problem with SQL query on PHP site

Hello All the code snippet below is from an osCommerce store I’m adding some extra functionality to.

It’s failing at this line [b]$thule_products_id = mysql_result($thule_products_id_query,0);[/b] with this error:
[i]
Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /home/faster/internal/http/www1/includes/application_top.php on line 388

Warning: Cannot modify header information – headers already sent by (output started at /home/faster/internal/http/www1/includes/application_top.php:388) in /home/faster/internal/http/www1/includes/functions/general.php on line 28[/i]

Does anyone know what is going wrong, I’ve also posted on the osCommerce forum but am still awaiting a reply so thought I’d ask you guys.

Here’s the code.

[code] // customer adds a product from the Thule Database
case ‘add_product_thule’ : if (isset($HTTP_POST_VARS[‘products_model’])) {
$tule_products_model = $HTTP_POST_VARS[‘products_model’];
$thulequery=”SELECT products_id FROM products WHERE products_model = $thule_products_model”;
$thule_products_id_query = mysql_query($thulequery);
$thule_products_id = mysql_result($thule_products_id_query,0);

$cart->add_cart($thule_products_id, $cart->get_quantity(tep_get_uprid($thule_products_id, $HTTP_POST_VARS[‘id’]))+1, $HTTP_POST_VARS[‘id’]);
}
tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
break;[/code]

Thanks

Paul

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@pauladkins1974authorJun 19.2007 — Problem fixed.

Just thought I'd let people know, who know's someone might need to use this.

[CODE]// customer adds a product from the Thule Database
case 'add_product_thule' : if (isset($HTTP_POST_VARS['products_model'])) {
$thule_products_model = $HTTP_POST_VARS['products_model'];
$thulequery="SELECT products_id FROM products WHERE products_model = '{$thule_products_model}'";
$thule_products_id_query = mysql_query($thulequery) or die(mysql_error());
$thule_products_id = mysql_result($thule_products_id_query,0);

$cart->add_cart($thule_products_id, $cart->get_quantity(tep_get_uprid($thule_products_id, $HTTP_POST_VARS['id']))+1, $HTTP_POST_VARS['id']);
}
tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
break;
[/CODE]
×

Success!

Help @pauladkins1974 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.9,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...