Page 1 of 1

what is wrong

Posted: Sun Jan 20, 2008 10:55 am
by jeremybass
hello, quick question... what is wrong with this....?

Code: Select all

if ($types_picked['extra_fields_type_cat_id'] == '999999999') {                                    
        $picked = 'true';
      } else {
        $picked = 'false';
      }
thank and have a great day

Re: what is wrong

Posted: Sun Jan 20, 2008 10:57 am
by John Cartwright
Depends, what are you trying to do?

Re: what is wrong

Posted: Sun Jan 20, 2008 11:00 am
by jeremybass
hello, um..... if 'extra_fields_type_cat_id' = '999999999' then $picked = 'true' } else { $picked = 'false'

i just what $picked to = true or faluse from 'extra_fields_type_cat_id'

Re: what is wrong

Posted: Sun Jan 20, 2008 11:06 am
by JAM
replace the if-clause with

Code: Select all

echo $types_picked['extra_fields_type_cat_id']
...and see what it says.

Re: what is wrong

Posted: Sun Jan 20, 2008 11:16 am
by jeremybass
damn nothing... it's located in a loop and is supost to check a checkbox feild if the extra_fields_type_cat_id=9999999 (meaning it is there or not only) then on refresh ....on and on...

here is the code for that area... may some will have an idea...

Code: Select all

<?php  
       echo tep_draw_form('extra_fields', FILENAME_SUPERFIELDSTYPE, 'action=update' . '&' . 'cPath=' . $cPath . '&pID=' . $pInfo->products_id,'post');
      ?>
<?php
$extra_fields_query_update = tep_db_query("SELECT * FROM " . TABLE_EXTRA_FIELDS_TYPE . " WHERE extra_fields_type_status=1 ORDER BY extra_fields_type_order");
$types_picked_query = tep_db_query("SELECT * FROM " . TABLE_PRODUCTS_TO_EXTRA_FIELDS . " WHERE products_id = '" . (int)$HTTP_GET_VARS['pID'] . "' and extra_fields_type_id='" .tep_db_input($key) . "'");
$types_picked = tep_db_fetch_array($types_picked_query);
while ($extra_fields = tep_db_fetch_array($extra_fields_query_update)) {
 
 
?>                        
<?php echo ($types_picked['extra_fields_type_cat_id'] == '999999999') {                                    
        $picked = 'true';
      } else {
        $picked = 'false';
      }; 
echo tep_draw_checkbox_field('mark['.$extra_fields['extra_fields_type_id'].']', $pInfo->products_id, $picked); ?>
<?php echo $extra_fields['extra_fields_type_name']; ?> &nbsp;&nbsp; 
 
<br/>
  <?php } ?> <?php echo tep_image_submit('button_update_fields.png',IMAGE_UPDATE_FIELDS); ?>
i hope the more eyes on it the better... thanks all for the fast reply... i think i'll have to stop in more often

Re: what is wrong

Posted: Sun Jan 20, 2008 11:18 am
by John Cartwright
What does

Code: Select all

 
echo '<pre>';
print_r($types_picked);
echo '</pre>';
yield?

Re: what is wrong

Posted: Sun Jan 20, 2008 11:23 am
by jeremybass
:( nothing...

Re: what is wrong

Posted: Sun Jan 20, 2008 11:30 am
by jeremybass
ok... you guys can't tell i'm new to php... only 4 months now.... now could the problem lay in my query sntax or placement?

Re: what is wrong

Posted: Sun Jan 20, 2008 11:34 am
by John Cartwright

Code: Select all

$types_picked_query = tep_db_query("SELECT * FROM " . TABLE_PRODUCTS_TO_EXTRA_FIELDS . " WHERE products_id = '" . (int)$HTTP_GET_VARS['pID'] . "' and extra_fields_type_id='" .tep_db_input($key) . "'");
your tep_db_query() is not returning any rows from the query. I'm not sure if you are expecting there to be a row(s) returned or not :S

A couple things we can move forward with.. try inserting this into your code. Take whatever is returned and try running the query in phpmyadmin to see if any rows are returned.

Code: Select all

echo "SELECT * FROM " . TABLE_PRODUCTS_TO_EXTRA_FIELDS . " WHERE products_id = '" . (int)$HTTP_GET_VARS['pID'] . "' and extra_fields_type_id='" .tep_db_input($key) . "'";
If you are getting some rows returned, then there is a problem with your tep_db_query() perhaps. Try posting that code as well please.

Re: what is wrong

Posted: Sun Jan 20, 2008 11:36 am
by John Cartwright
Try replacing all instances of $HTTP_GET_VARS with $_GET also.

$HTTP_GET_VARS is deprecated.

Re: what is wrong

Posted: Sun Jan 20, 2008 11:47 am
by jeremybass
ok so i tryed it and found the error in the query

Code: Select all

<?php  
       echo tep_draw_form('extra_fields', FILENAME_SUPERFIELDSTYPE, 'action=update' . '&' . 'cPath=' . $cPath . '&pID=' . $pInfo->products_id,'post');
      ?>
<?php
$extra_fields_query_update = tep_db_query("SELECT * FROM " . TABLE_EXTRA_FIELDS_TYPE . " WHERE extra_fields_type_status=1 ORDER BY extra_fields_type_order");
$types_picked_query = tep_db_query("SELECT * FROM " . TABLE_PRODUCTS_TO_EXTRA_FIELDS . " WHERE products_id = '" . (int)$HTTP_GET_VARS['pID'] . "' and extra_fields_type_id='" . $extra_fields['extra_fields_type_id'] . "'");
$types_picked = tep_db_fetch_array($types_picked_query);
while ($extra_fields = tep_db_fetch_array($extra_fields_query_update)) {
 
 
?>                        
<?php if ($types_picked['extra_fields_type_cat_id'] == '999999999') {                                    
        $picked = 'true';
      } else {
        $picked = 'false';
      } 
echo tep_draw_checkbox_field('mark['.$extra_fields['extra_fields_type_id'].']', $pInfo->products_id, $picked); ?>
<?php echo $extra_fields['extra_fields_type_name']; ?> &nbsp;&nbsp; 
 
<br/>
  <?php } ?> <?php echo tep_image_submit('button_update_fields.png',IMAGE_UPDATE_FIELDS); ?> </form>
so those are the changes that make the out-put right but another proble poped up lol... always the case...

Code: Select all

      tep_db_query("INSERT INTO " . TABLE_PRODUCTS_TO_EXTRA_FIELDS . " (products_id, extra_fields_type_id) VALUES (" . tep_db_input((int)$HTTP_GET_VARS['pID']) . ", " .tep_db_input($key) . ") ON DUPLICATE KEY UPDATE products_id=" . tep_db_input((int)$HTTP_GET_VARS['pID']) . ", extra_fields_type_id=" .tep_db_input($key) . ";");
 
is creating duplicated rows... but still the if lause is not working right....

Re: what is wrong

Posted: Sun Jan 20, 2008 11:47 am
by jeremybass
Try replacing all instances of $HTTP_GET_VARS with $_GET also.

$HTTP_GET_VARS is deprecated.
well try

Re: what is wrong

Posted: Sun Jan 20, 2008 11:56 am
by jeremybass

Code: Select all

    tep_db_query("INSERT INTO " . TABLE_PRODUCTS_TO_EXTRA_FIELDS . " (products_id, extra_fields_type_id) VALUES (" . tep_db_input((int)$HTTP_GET_VARS['pID']) . ", " .tep_db_input($key) . ") ON DUPLICATE KEY UPDATE products_id=" . tep_db_input((int)$HTTP_GET_VARS['pID']) . ", extra_fields_type_id=" .tep_db_input($key) . ";");
never mind on that... forgot i turns the defult in phpMyAdmin was off... no luck with the if clase

Re: what is wrong

Posted: Sun Jan 20, 2008 12:17 pm
by jeremybass
ok $types_picked is returning an array set.... but the if is half working
output is
---------------------------------------------
is checked (suppost to be)

1
tArray
(
[products_id] => 75
[extra_fields_type_id] => 39
[extra_fields_type_cat_id] => 999999999
[extra_fields_type_cat_values_id] => 999999999
)
SELECT * FROM products_to_extra_fields WHERE products_id = '75' and extra_fields_type_id='39'Processor
------------------------------------------------
is checked (not suppost to be)

tSELECT * FROM products_to_extra_fields WHERE products_id = '75' and extra_fields_type_id='55'ffff

----------------------------------------------------

lastest code

Code: Select all

<?php  
       echo tep_draw_form('extra_fields', FILENAME_SUPERFIELDSTYPE, 'action=update' . '&' . 'cPath=' . $cPath . '&pID=' . $pInfo->products_id,'post');
      ?>
<?php
$extra_fields_query_update = tep_db_query("SELECT * FROM " . TABLE_EXTRA_FIELDS_TYPE . " WHERE extra_fields_type_status=1 ORDER BY extra_fields_type_order");
 
while ($extra_fields = tep_db_fetch_array($extra_fields_query_update)) {
$types_picked_query = tep_db_query("SELECT * FROM " . TABLE_PRODUCTS_TO_EXTRA_FIELDS . " WHERE products_id = '" . (int)$_GET['pID'] . "' and extra_fields_type_id='" . $extra_fields['extra_fields_type_id'] . "'");
$types_picked = tep_db_fetch_array($types_picked_query);
echo ($types_picked['extra_fields_type_cat_id'] == 999999999);
if ($types_picked['extra_fields_type_cat_id'] == 999999999) {                                    
        $picked = 'true';
      } else {
        $picked = 'false';
      } 
      
 
?>                        
<?php 
      echo '<pre>t';
print_r($types_picked);
echo '</pre>';
echo "SELECT * FROM " . TABLE_PRODUCTS_TO_EXTRA_FIELDS . " WHERE products_id = '" . (int)$_GET['pID'] . "' and extra_fields_type_id='" . $extra_fields['extra_fields_type_id'] . "'";
echo tep_draw_checkbox_field('mark['.$extra_fields['extra_fields_type_id'].']', $pInfo->products_id, $picked); ?>
<?php echo $extra_fields['extra_fields_type_name']; ?> &nbsp;&nbsp; 
 
<br/>
  <?php } ?> <?php echo tep_image_submit('button_update_fields.png',IMAGE_UPDATE_FIELDS); ?> </form>

Re: what is wrong

Posted: Sun Jan 20, 2008 12:34 pm
by jeremybass
got it... it was the ' ' around the true false.... i'll have to remeber to debug like that... works great... thanks all..