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

Link to comment
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.