holladb Posted February 7, 2008 Share Posted February 7, 2008 Hey i cant figure this out. I just got a new debian server for our client using PHP5 and the GD Library. My problem is that I can't figure out why one of the tables isn't pulling from the database. http://www.idealclothing.net everything is fine and the images work. On our offline new debian server everything works fine except the images. We're using a custom templating system. The code doesn't seem to be transfering over the "src" on the new server. Here is the code where it's supposed to be pulling. <? require_once 'inc/config.inc.php'; $id = intval($id); $db->setTable($GLOBALS['t_items']); $irow = $db->get("id='$id'"); //echo $id; exit; //echo "<pre>"; print_r($irow); exit; $no_list = $db->get("id='".$irow['categories_id']."'", 'is_no_list', $GLOBALS['t_categories']); $tpl->loadTemplatefile('contentb'); $db->setTable($GLOBALS['t_brands']); $rows = $db->select("categories_id='".$irow['categories_id']."' and name!=''", 'name'); $alias = $db->get('id='.intval($irow['categories_id']), 'alias', $GLOBALS['t_categories']); if (isset($rows)&&is_array($rows)) { if ($no_list != 1 && $irow['brandid'] != '') { array_unshift($rows, array('category_alias'=> $alias, 'name' => 'All')); } foreach ($rows as $row) { $row[name] = str_replace(' ', ' ', $row[name]); if ($irow['brandid'] == $row['id']) { $tpl->setCurrentBlock('brands_active_link'); $tpl->setVariable(array( 'category_alias'=> $alias, 'alias' => $row['alias'], 'name' => $row['name'], 'is_new' => ($row['is_new'])?'':null, 'is_clearance' => ($row['is_clearance'])?'':null )); } else { $tpl->setCurrentBlock('brands_inactive_row'); $tpl->setVariable(array( 'category_alias'=> $alias, 'alias' => $row['alias'], 'name' => $row['name'], 'is_new' => ($row['is_new'])?'':null, 'is_clearance' => ($row['is_clearance'])?'':null )); } $tpl->parseCurrentBlock(); $tpl->setCurrentBlock('brands'); $tpl->parseCurrentBlock(); } } $contentb = $tpl->get(); $row = $irow; $multiple_images = false; $tpl->loadTemplatefile('item_new'); $file_info = getImage('items', $row['image']); if ($file_info['src'] != '') { $first_src = $file_info['src']; $row['src'] = $file_info['src']; $row['width'] = $file_info['width']; $row['height'] = $file_info['height']; } //echo "<pre>"; print_r($row); exit; $row['is_new'] = ($row['is_new'])?'':null; $row['is_sale'] = (($row['is_sale']) ? (($row['original_price'] > 0) ? ('(Original Price: $'.$row['original_price'].')') : "") : null); $row['description'] = nl2br($row['description']); $row['from_date'] = ($row['from_date'] == '' || $row['from_date'] == '0000-00-00')?null:dateFormat($row['from_date']); $row['to_date'] = ($row['to_date'] == '' || $row['to_date'] == '0000-00-00')?null:dateFormat($row['to_date']); $file_info = getImage('items', $row['second']); if ($file_info['src']) { $tpl->setCurrentBlock('second_image'); $multiple_images = true; $im = array(); $im['src'] = $file_info['src']; $im['id'] = $id; if((int)$_GET['image'] == 2) { $row['src'] = $file_info['src']; } $tpl->setVariable($im); $tpl->parseCurrentBlock(); } $file_info = getImage('items', $row['third']); if ($file_info['src']) { $tpl->setCurrentBlock('third_image'); $multiple_images = true; $im = array(); $im['src'] = $file_info['src']; $im['id'] = $id; if((int)$_GET['image'] == 3) { $row['src'] = $file_info['src']; } $tpl->setVariable($im); $tpl->parseCurrentBlock(); } $file_info = getImage('items', $row['fourth']); if ($file_info['src']) { $tpl->setCurrentBlock('fourth_image'); $multiple_images = true; $im = array(); $im['src'] = $file_info['src']; $im['id'] = $id; if((int)$_GET['image'] == 4) { $row['src'] = $file_info['src']; } $tpl->setVariable($im); $tpl->parseCurrentBlock(); } $file_info = getImage('items', $row['fifth']); if ($file_info['src']) { $tpl->setCurrentBlock('fifth_image'); $multiple_images = true; $im = array(); $im['src'] = $file_info['src']; $im['id'] = $id; if((int)$_GET['image'] == 5) { $row['src'] = $file_info['src']; } $tpl->setVariable($im); $tpl->parseCurrentBlock(); } $file_info = getImage('items', $row['swatch']); if ($file_info['src']) { $tpl->setCurrentBlock('swatch_image'); $im = array(); $im['src'] = $file_info['src']; if($row['swatch_text']) { $im['swatch_text_message'] = nl2br($row['swatch_text']); } else { $im['swatch_text_message'] = 'Color Swatch'; } $tpl->setVariable($im); $tpl->parseCurrentBlock(); } // Only display the first thumbnail if there are others... if ($row['src'] && $multiple_images) { $tpl->setCurrentBlock('first_image'); $im = array(); $im['src'] = $first_src; $im['id'] = $id; $tpl->setVariable($im); $tpl->parseCurrentBlock(); } for ($i=1;$i<=5;$i++) { $db->setTable($GLOBALS['t_items_params']); $prows = $db->select("items_id='".$row['id']."' AND params_id='$i'", 'id'); // sort($prows); // echo "<pre>"; print_r($prows); $options = ''; $list = ''; if (isset($prows) && is_array($prows)) { foreach ($prows as $prow) { $options .= '<option value="'.$prow[name].'">'.$prow[name]; if ($list != '') $list .= ','; $list .= $prow[name]; } } $row['param'.$i.'_name'] = $ITEMS_PARAMS[$i]; $row['param'.$i.'_options'] = $options; } $brand_data = $db->get("id='".intval($row['brandid'])."'", '', $GLOBALS['t_brands']); $stext = $db->get("id='".$brand_data['size_charts_id']."'", 'text', $GLOBALS['t_size_charts']); if ($stext == '') { unset($row['brandid']); } $tpl->setVariable($row); $_SESSION['ideal_back'] = 'item.php?id='.$id; $item_id = $id; parseGlobal('global', $contentb); $db->disconnect(); $tpl->show(); ?> Quote Link to comment Share on other sites More sharing options...
Moon-Man.net Posted February 7, 2008 Share Posted February 7, 2008 I could be wrong, but if it is working on one server, but not the next. I would say its a PHP enviroment issue? Maybe check php.ini between the two servers? Quote Link to comment Share on other sites More sharing options...
holladb Posted February 7, 2008 Author Share Posted February 7, 2008 did that, didn't really see any major issues that would make it not work. I'm thinking more along the lines of apache possibly. Quote Link to comment Share on other sites More sharing options...
Moon-Man.net Posted February 7, 2008 Share Posted February 7, 2008 I don't think apache has much to do with PHP at all. As far as I'm aware PHP runs the code, and simply hands Apache the HTML to be served via http. Are the GD library's installed correctly and loaded? Maybe make a small test page. Just throwing idea's. Quote Link to comment Share on other sites More sharing options...
holladb Posted February 7, 2008 Author Share Posted February 7, 2008 gd lib works fine, the problem is it's not transferring over the $file_info['src']. Quote Link to comment Share on other sites More sharing options...
Moon-Man.net Posted February 7, 2008 Share Posted February 7, 2008 add a print_r($file_info); somewhere and see if it contains the details it should. Where does this get_image(); function come from? Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted February 7, 2008 Share Posted February 7, 2008 Have you echoed out the variable so that you know if or what it contains? Is the data present in the database? If the images are generated by GD, post the code responsible for outputting the images. If you browse directly to a URL for an image does the image display? Quote Link to comment Share on other sites More sharing options...
holladb Posted February 7, 2008 Author Share Posted February 7, 2008 the code generating the images is fine. it does that. tested and works. As far as it holding the data, yes it does. The function responsible for pulling the image from the database however does not work. function getImage($table, $value) { if ($value == '') { return array(); } eval('$path = '.strtoupper($table.'_path').';'); $path = FILES_PATH.$path; $file_name = $path.$value; if (file_exists($file_name)) { $file_info = getimagesize($file_name); return array( 'src' => '/'.$file_name, 'width' => $file_info[0], 'height' => $file_info[1], ); } return array(); } I did a little test just changing the above to something standard like "/files.jpg"; and it outputted src=/ It looks like some where there is an error where it's only allow the variable to handle 1 character. Quote Link to comment Share on other sites More sharing options...
Moon-Man.net Posted February 7, 2008 Share Posted February 7, 2008 $path = FILES_PATH.$path; Could that be an issue? FILES_PATH? Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted February 8, 2008 Share Posted February 8, 2008 I recommend turning on full php error reporting then check your web server log for errors. This would tell you if variables, constants, paths... are not found. Quote Link to comment Share on other sites More sharing options...
holladb Posted February 8, 2008 Author Share Posted February 8, 2008 Prior to turning off all errors i was receiving one error notice. But it didn't seem to be an issue with the pages it showed up on as all the functions were working. php Notice: Undefined variable: Quote Link to comment Share on other sites More sharing options...
holladb Posted February 8, 2008 Author Share Posted February 8, 2008 anybody anybody? Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted February 8, 2008 Share Posted February 8, 2008 You are using short_tags "<?", try using "<?php" instead. Ken Quote Link to comment Share on other sites More sharing options...
laffin Posted February 8, 2008 Share Posted February 8, 2008 [code]look at yer code closely [code]eval('$path = '.strtoupper($table.'_path').';'); $path = FILES_PATH.$path; $file_name = $path.$value; if (file_exists($file_name)) { there is no need for using eval here. but these 3 lines, convert a directory name to full uppercase. under windows, this dusn really matter. under linux, it matters so when it fails to find the proper path, it dusn set anything. as for the eval in the code, this does the same thing [/code]'$path = FILES_PATH . strtoupper($table.'_path'); $file_name = $path.$value; if (file_exists($file_name)) {[/code] Quote Link to comment Share on other sites More sharing options...
holladb Posted February 11, 2008 Author Share Posted February 11, 2008 no luck yet... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.