woocha Posted December 17, 2007 Share Posted December 17, 2007 Can someone tell me why this bit of code craps out? $item_file = $r['item_numb']; $item_file .= '.php'; $file_location = "$_SERVER['DOCUMENT_ROOT'].'/mall/$merchantdir/$item_file'"; Line # cause me to have a blank screen...any thoughts? Link to comment https://forums.phpfreaks.com/topic/82087-solved-poor-php-code-and-need-helpany-thoughts/ Share on other sites More sharing options...
paul2463 Posted December 17, 2007 Share Posted December 17, 2007 Can someone tell me why this bit of code craps out? $item_file = $r['item_numb']; $item_file .= '.php'; $file_location = "$_SERVER['DOCUMENT_ROOT'].'/mall/$merchantdir/$item_file'"; Line # cause me to have a blank screen...any thoughts? what do you do with the string $file_location??? Link to comment https://forums.phpfreaks.com/topic/82087-solved-poor-php-code-and-need-helpany-thoughts/#findComment-417105 Share on other sites More sharing options...
woocha Posted December 17, 2007 Author Share Posted December 17, 2007 checking to see if it exists one folder back from the execute script on the server Link to comment https://forums.phpfreaks.com/topic/82087-solved-poor-php-code-and-need-helpany-thoughts/#findComment-417106 Share on other sites More sharing options...
paul2463 Posted December 17, 2007 Share Posted December 17, 2007 when you said it leads to a blank page, are you directing the browser to the address $file_location? Link to comment https://forums.phpfreaks.com/topic/82087-solved-poor-php-code-and-need-helpany-thoughts/#findComment-417108 Share on other sites More sharing options...
woocha Posted December 17, 2007 Author Share Posted December 17, 2007 no... here the more of the code...soryy if I wasn't being descriptive enough...I am eating cheezey curls $item_file = $r['item_numb']; $item_file .= '.php'; $file_location = "$_SERVER['DOCUMENT_ROOT'].'/mall/$merchantdir/$item_file'"; if(file_exists($file_location)) { echo "<td valign=top align=center><font size=2>".$item_file; } else { something else} when I replace $file_location = "$_SERVER['DOCUMENT_ROOT'].'/mall/$merchantdir/$item_file'"; with a direct http://www.example.com//mall/$merchantdir/$item_file, the script works fine, But I really want to know why i can't use the doc root instead of the direct path Link to comment https://forums.phpfreaks.com/topic/82087-solved-poor-php-code-and-need-helpany-thoughts/#findComment-417112 Share on other sites More sharing options...
paul2463 Posted December 17, 2007 Share Posted December 17, 2007 try this <?php $item_file = $r['item_numb']; $item_file .= '.php'; $root = $_SERVER['DOCUMENT_ROOT']; $file_location = "$root/mall/$merchantdir/$item_file"; if(file_exists($file_location)) { echo "<td valign=top align=center><font size=2>".$item_file; } else { something else} ?> Link to comment https://forums.phpfreaks.com/topic/82087-solved-poor-php-code-and-need-helpany-thoughts/#findComment-417114 Share on other sites More sharing options...
woocha Posted December 17, 2007 Author Share Posted December 17, 2007 That worked out great....Thank you Link to comment https://forums.phpfreaks.com/topic/82087-solved-poor-php-code-and-need-helpany-thoughts/#findComment-417115 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.