Jump to content

[SOLVED] poor PHP Code and need help...any thoughts


woocha

Recommended Posts

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???

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

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}
?>

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.