Zen Cart Logo
Forums / Basic Configuration / What's wrong with this query ?

What's wrong with this query ?

Locked

Views: 1,608

Results 1 to 6 of 6
This thread is locked. New replies are disabled.
08 Jul 2006, 05:24
#1
emmdee avatar

emmdee

New Zenner

Join Date:
Nov 2005
Posts:
40
Plugin Contributions:
0

What's wrong with this query ?

Can anyone tell me what's wrong with this query ? I want to make a popup page that just gives a bit more info. Got the popup workin ok but cant get this to work.....My coding is poor
and all I want to pull up is product description. It seems to get parsed alright,
but will not echo $prod_desc....or is the problem in my variables?
Can anyone help????
Cheers
Emmdee

$sql = "select distinct products_id, products_name, products_description, language_id
                        
     from      ".  PRODUCTS_DESCRIPTION ." 
       
   where          products_id='" . (int)$_GET['products_id'] . "'
       
        and            language_id = '" . (int)$_SESSION['languages_id'] . "' " .

$prod = $db->Execute($sql);

echo 'Prod ID - '.(int)$_GET['products_id'] . '';

$prod_desc = $prod_lookup->fields['products_description'];

echo $prod_desc;

08 Jul 2006, 06:27
#2
superprg avatar

superprg

Totally Zenned

Join Date:
Feb 2006
Location:
Chicago
Posts:
1,349
Plugin Contributions:
0

Re: What's wrong with this query ?

emmdee:

Can anyone tell me what's wrong with this query ? I want to make a popup page that just gives a bit more info. Got the popup workin ok but cant get this to work.....My coding is poor
and all I want to pull up is product description. It seems to get parsed alright,
but will not echo $prod_desc....or is the problem in my variables?
Can anyone help????
Cheers
Emmdee

$sql = "select distinct products_id, products_name, products_description, language_id
                        
     from      ".  PRODUCTS_DESCRIPTION ." 
       
   where          products_id='" . (int)$_GET['products_id'] . "'
       
        and            language_id = '" . (int)$_SESSION['languages_id'] . "' " .

$prod = $db->Execute($sql);

echo 'Prod ID - '.(int)$_GET['products_id'] . '';

$prod_desc = $prod_lookup->fields['products_description'];

echo $prod_desc;

$prod_desc = $prod_lookup->fields['products_description'];

Where is $prod_lookup???
use
$prod_desc = $prod->fields['products_description'];

08 Jul 2006, 06:38
#3
superprg avatar

superprg

Totally Zenned

Join Date:
Feb 2006
Location:
Chicago
Posts:
1,349
Plugin Contributions:
0

Re: What's wrong with this query ?

Alternatively, you can use this

$num=mysql_numrows($prod);
i=0;
while ($i < $num) {
$prod_desc=mysql_result($prod,$i,"products_id")
echo $prod_desc;
$i++;
}

09 Jul 2006, 04:18
#4
emmdee avatar

emmdee

New Zenner

Join Date:
Nov 2005
Posts:
40
Plugin Contributions:
0

Re: What's wrong with this query ?

Thanks superprg for your reply. I've tried both of your suggestions and am still getting no joy. I just don't get it. I've made a pop-up info page and put the link to it on the product_info page (Version 1.27). This works fine and product_id is being posted over ok. I'm testing locally on pws and php 4.3, mysql <5 not sure which, but pretty recent.
$sql = "select PRODUCTS_DESCRIPTION.products_description, PRODUCTS_DESCRIPTION.products_name
from ". PRODUCTS_DESCRIPTION ."
where products_id='" . (int)$_GET['products_id'] . "' ".
$prod = $db->Execute($sql);
echo 'Prod ID - '.(int)$_GET['products_id'] . '';*****THE GET PROD ID PRINTS OK.
$prod_desc = $prod->fields['products_description'];
echo $prod_desc;
THIS PARSES OK, BUT I'M GETTING NO RESULT....
THE ALTERNATIVE BELOW GIVES AN UNEXPECTED T_ECHO ERROR...I changed the variable i to $i, cause it gives an UNEXPECTED = ERROR
//$num=mysql_numrows($prod);
//$i=0;
//while ($i < $num) {
//$prod_desc=mysql_result($prod,$i,"products_id")
//echo 'desc'. $prod_desc;
//$i++
Driving me nuts...regards emmdee

09 Jul 2006, 04:26
#5
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: What's wrong with this query ?

Simple syntax error ... you ended a PHP command with a . instead of a ;

$sql = "select distinct products_id, products_name, products_description, language_id

from ". PRODUCTS_DESCRIPTION ."

where products_id='" . (int)$_GET['products_id'] . "'

and language_id = '" . (int)$_SESSION['languages_id'] . "' " . <--here

$prod = $db->Execute($sql);

echo 'Prod ID - '.(int)$_GET['products_id'] . '';

$prod_desc = $prod->fields['products_description'];

echo $prod_desc;

10 Jul 2006, 05:21
#6
emmdee avatar

emmdee

New Zenner

Join Date:
Nov 2005
Posts:
40
Plugin Contributions:
0

Re: What's wrong with this query ?

Thanks Doctor.....all is fine now
regards
emmdee