code works on server A, but not server B, need help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
inosent
Forum Newbie
Posts: 4
Joined: Fri Mar 16, 2007 1:51 pm

code works on server A, but not server B, need help

Post by inosent »

Hi

I have a web page that upon submission creates a link to click on, which is a FDF file (data file for a PDF file), when clicked, places the contents of the fdf file into the pdf file.

to see this working go to

http://inovacapitalmanagement.com/adpf

Code: Select all

<?php
    require_once 'createFDF.php';
  $pdf_file='http://www.inovacapitalmanagement.com/apdf/v12.pdf';

    // allow for up to 25 different files to be created, based on the minute
    $min=date('i') % 25;
    
$fdf_file=dirname(__FILE__).'/results/posted-'.$min.'.fdf';
    if(isset($_POST['b_fname'])){
        $_POST['b_cphone']=$_POST['b_cphone'];

        // get the FDF file contents
        $fdf=createFDF($pdf_file,$_POST);

        // Create a file for later use
        if($fp=fopen($fdf_file,'w')){
            fwrite($fp,$fdf,strlen($fdf));
            $CREATED=TRUE;
        }else{
            echo 'Unable to create file: '.$fdf_file.'<br><br>';
            $CREATED=FALSE;
        }
        fclose($fp);
    }
?>

Code: Select all

<?php

function createFDF($file,$info){
    $data="%FDF-1.2\n%âãÏÓ\n1 0 obj\n<< \n/FDF << /Fields [ ";
    foreach($info as $field => $val){
    	if(is_array($val)){
        	$data.='<</T('.$field.')/V[';
        	foreach($val as $opt)
        		$data.='('.trim($opt).')';
        	$data.=']>>';
    	}else{
        	$data.='<</T('.$field.')/V('.trim($val).')>>';
    	}
    }
    $data.="] \n/F (".$file.") /ID [ <".md5(time()).">\n] >>".
        " \n>> \nendobj\ntrailer\n".
        "<<\n/Root 1 0 R \n\n>>\n%%EOF\n";
    return $data;
}
?>

but at this site:

http://www.americanlaw1.com/apdf

instead of, after clicking on the result link the pdf file, i get the text of the fdf file instead, which naturally drives me crazy, because i dont understand how the same code will work on one server but not the next:

Code: Select all

<?php
    require_once 'createFDF.php';
  $pdf_file='http://www.americanlaw1.com/apdf/v12.pdf';

    // allow for up to 25 different files to be created, based on the minute
    $min=date('i') % 25;
    
$fdf_file=dirname(__FILE__).'/results/posted-'.$min.'.fdf';
    if(isset($_POST['b_fname'])){
        $_POST['b_cphone']=$_POST['b_cphone'];

        // get the FDF file contents
        $fdf=createFDF($pdf_file,$_POST);

        // Create a file for later use
        if($fp=fopen($fdf_file,'w')){
            fwrite($fp,$fdf,strlen($fdf));
            $CREATED=TRUE;
        }else{
            echo 'Unable to create file: '.$fdf_file.'<br><br>';
            $CREATED=FALSE;
        }
        fclose($fp);
    }
?>

The permissions for the 'results' folder at site 1 is 755. but if i try 755 at site 2 it wont allow the creation of the fdf file. but if i change the permissions of the results folder at site 2 to 777 the fdf file will get created, but then when i click on the results link all i get is the text of the fdf file.
User avatar
Jade
Forum Regular
Posts: 908
Joined: Sun Dec 29, 2002 5:40 pm
Location: VA

Re: code works on server A, but not server B, need help

Post by Jade »

Have you turned all errors on? The second server may be suppressing an error that's causing the problem.
Post Reply