PHP not rendering correctly

Discussion in 'HTML / PHP / JavaScript / CSS' started by ryanfestoco, Jun 22, 2009.

  1. Hi,

    I recently downloaded a flash template and am trying to use it on my site, but it seems as though the php files are not rendering correctly. Is there something I am doing wrong? Please bare in mind I know very little about PHP.

    Example: http://www.faheyphotography.net/install.php

    Thanks,

    -Ryan
     
  2. How are you coding your PHP? Do you have <$php and ?> in your script line to let the server know that this line is to be enabled in php?
     
  3. mjp

    mjp

    Try changing the single quotes to double quotes in lines 16 and 25.

    Change these:

    fwrite($File,'<?'.LF);
    fwrite($File,'?>'.LF);

    To this:

    fwrite($File,"<?".LF);
    fwrite($File,"?>".LF);

    Basically, a string enclosed in double quotes is parsed by PHP, so single quotes are generally used for literal text values. You know, basically and generally. ;) But there are exceptions to that, of course. What fun would it be if a rule was always a rule?

    Anyway, try the change, it should work. You can see when you look at the page now that the code is not being parsed after line 25. That's why your page starts with:

    '.LF); fclose($File); print '
     
  4. Thanks for the replies. I will definitely try them out when I get home tonight after work. I figured it was probably something simple like that (script line, quotes...), but like I mentioned before, I'm not familiar with the PHP language so I just couldn't pinpoint the issue myself. Thanks again. I will let you know how it goes.

    -Ryan
     
  5. Neither of those seemed to work. The pages still render the same. I talked to the people I downloaded the template from and they said that it might be a hosting problem. Any other ideas?

    Here is code for install.php:

    <$php
    header('Content-type: text/html; charset=UTF-8');
    include("inc/header.php");
    define('LF', chr(10));
    $adm_login=$_POST['adm_login'];
    $adm_pass=$_POST['adm_pass'];
    $gallery_path=$_POST['gallery_path'];
    $pic_max_size_x=$_POST['pic_max_size_x'];
    $pic_max_size_y=$_POST['pic_max_size_y'];
    $thumb_size_x=$_POST['thumb_size_x'];
    $thumb_size_y=$_POST['thumb_size_y'];
    if ($adm_login&&$adm_pass&&$gallery_path&&$pic_max_size_x&&$pic_max_size_y&&$thumb_size_x&&$thumb_size_y) {
    $File=fopen('config.php','w');
    fwrite($File,"<?".LF);
    fwrite($File,'$admin_login="'.$adm_login.'";'.LF);
    fwrite($File,'$admin_pass="'.$adm_pass.'";'.LF);
    fwrite($File,'$gallery_path="'.$gallery_path.'";'.LF);
    fwrite($File,'$pic_max_size_x="'.$pic_max_size_x.'";'.LF);
    fwrite($File,'$pic_max_size_y="'.$pic_max_size_y.'";'.LF);
    fwrite($File,'$thumb_size_x="'.$thumb_size_x.'";'.LF);
    fwrite($File,'$thumb_size_y="'.$thumb_size_y.'";'.LF);
    fwrite($File,"?>".LF);
    fclose($File);
    print '<table><tr><td style="color:#ffffff">';
    print 'Installed.<br />';
    print '1. Delete file install.php<br />2. Change attributes to 0755 for config.php.<br /> 3. Change attributes to 0777 for folder "Gallery".<br />';
    print 'Link to Admin.panel: <a href="admin.php">admin.php</a>';
    print '</td></tr></table>';
    } else {
    print '<table><tr><td style="color:#FFFFFF ">';
    print '<b>Please change attributes to 0777 for config.php and folder gallery</b><br />';
    print '<br />';
    print '<form name="form1" method="post" action="install.php">';
    print ' Enter admin login: <input type="text" name="adm_login" / style="border-color:#777777; border-width:1px; border-style:solid; background-color:#000000; color:#777777 "><br><br style="line-height:6px ">';
    print ' Enter admin password: <input name="adm_pass" type="password" / style="border-color:#777777; border-width:1px; border-style:solid; background-color:#000000; color:#777777 "><br><br><br style="line-height:6px ">';
    print ' Path to gallery: <input type="text" name="gallery_path" value="gallery" / style="border-color:#777777; border-width:1px; border-style:solid; background-color:#000000; color:#777777 "><br><br style="line-height:6px ">';
    print ' Max size of new pics (x): <input type="text" name="pic_max_size_x" value="500" / style="border-color:#777777; border-width:1px; border-style:solid; background-color:#000000; color:#777777 "><br><br style="line-height:6px ">';
    print ' Max size of new pics (y): <input type="text" name="pic_max_size_y" value="500" / style="border-color:#777777; border-width:1px; border-style:solid; background-color:#000000; color:#777777 "><br><br style="line-height:6px ">';
    print ' Size of thumbnails (x): <input type="text" name="thumb_size_x" value="50" / style="border-color:#777777; border-width:1px; border-style:solid; background-color:#000000; color:#777777 "><br><br style="line-height:6px ">';
    print ' Size of thumbnails (y): <input type="text" name="thumb_size_y" value="50" / style="border-color:#777777; border-width:1px; border-style:solid; background-color:#000000; color:#777777 "><br><br style="line-height:6px ">';
    print ' <input type="submit" value="" name="Submit" style="width:78px; height:21px; border-width:0px; border-style:solid; background-image:url(pics/submit.jpg)"/>';
    print '</form>';
    print '</td></tr></table>';
    };
    print "</body></html>";
    ?>
     
  6. I got it to work. I used <?php and it rendered correctly. Thanks for the help!!
     

Share This Page