none
Preview PHP pages in Expression Web 4 RRS feed

  • Question

  • I have looked at a lot of different threads and none have addressed my issue of getting a blank page trying to preview a php page through the Microsoft Expression Development Server.  I thought maybe I had the wrong version of PHP or something. 

    There are the steps I did:

    I deleted the PHP folder under the C:\ drive (for some reason it is no in my recycle bin so I cannot restore it)

    I went to PHP.NET to get the version that matches the production server.  That is version 5.3.28.

    I downloaded it to Documents\Downloads. 

    I created a PHP folder in the root of the C:\ drive and extracted the files to that folder. It was actually a zip inside a zip so I moved them to the Downloads folder and extracted the second zip to the C:\PHP folder.  I saw lots of files in there this time.

    I then looked for the PHP-INI-recommnded file and it was not there.  I had PHP.INI-production and PHP.INI-development.  I copied the PHP-INI-production file and renamed it to PHP.INI. (the second time I copied the PHP.INI-development file and renamed it to PHP.INI). 

    I then went to Expression Web 4, Site menu, Site Settings, Preview tab and set it to Use Microsoft Expression Development Server, For only PHP and ASP.NET web pages.  The instructions said I could set Path to PHP executable for previewing PHP pages in this site, and click Browse to locate and select php-cgi.exe but there is no php-cgi.exe anywhere in the PHP folder nor any subfolders.

    I thought I had done something wrong so I started the process over choosing the second zip file on PHP.NET for version 5.3.28.

    I got the same results as before.  No php-cgi.exe file.

    There are higher versions of PHP on PHP.NET but I don't want to use a higher version than what is on the production server. 

    What do I do now?  How do I get PHP with a php-cgi.exe file so I can preview PHP pages using the Microsoft Expression Development Server?


    mjmart61

    Wednesday, July 30, 2014 11:08 PM

Answers

  • If PHPinfo ran, then PHP is installed, EW is finding the exe, the PHP pages are being previewed by the development server, and there is nothing else related to EW that needs fixing.

    I'm sorry, but there is no way to know why your form PHP page is not previewing, but it's related to the page, maybe to resources it is using that are on the site but are not local, or who knows what else, but not to EW's setup.



    • Edited by KathyW2 Thursday, July 31, 2014 5:49 PM
    • Marked as answer by mjmart61 Thursday, July 31, 2014 8:03 PM
    Thursday, July 31, 2014 5:47 PM
  • Correct. The fact that the phpinfo page is displaying as expected indicates that there is nothing wrong with your PHP installation, and that EW's development server is launching, processing the PHP in the page, and rendering the resulting HTML out to the browser. So, basically, the only element that is not working as expected is the test page that you are trying to render.

    This could mean that you have one or more include files that are available on the production machine but that are not available locally, or that you have database connections that are valid on the production machine but not locally, or any of a number of other issues.

    The point is, even if you installed an *AMP stack to  create an instance of Apache, and tried to test using another dev package that doesn't have its own dev server like EW, you would face the same issues. The problem, clearly, is not with the server or with PHP, since both are working if you are able to view the phpinfo page, but with the page that you are trying to test locally. Have you thoroughly reviewed the PHP code of the test page to determine if there are any resources accessed from local relative paths that are available remotely but not locally?

    cheers,
    scot


    Please remember to "Mark as Answer" the responses that resolved your issue. It is common courtesy to recognize those who have helped you, and it also makes it easier for visitors to find the resolution later.

    • Marked as answer by mjmart61 Thursday, July 31, 2014 10:09 PM
    Thursday, July 31, 2014 9:45 PM

All replies

  • Where did you download the PHP files from?  Did you follow the links to the Windows versions?

    If you download the zip file from http://windows.php.net/download/ it definitely contains the php-cgi.exe file.

    Extract the zip file where you want to install PHP, copy the php.ini-production file and rename it php.ini, point EW to the location of the php-cgi.exe, and create a php page that has the following markup:

    <?php
    phpinfo();
    ?>

    Preview the page.  The first time you do EW will want to modify the php.ini file.  Say yes.  (If the php.ini file is located in a directory that EW can't write to, close EW and run it as an administrator, and try again.)

    When you preview the above page, you'll see a detailed display of the properties of your PHP installation.


    • Edited by KathyW2 Thursday, July 31, 2014 3:19 AM
    Thursday, July 31, 2014 2:59 AM
  • PHP.NET and there are only two listed for version 5.3.28 and I tried both of them.

    mjmart61

    Thursday, July 31, 2014 3:15 AM
  • I modified my reply with more details.  Please make sure you have downloaded the Windows version.
    Thursday, July 31, 2014 3:21 AM
  • Thank you very much. I will try your suggestions tomorrow. I will let you know my results as soon as I can.

    mjmart61

    Thursday, July 31, 2014 3:51 AM
  • I have done the steps you suggested.  I downloaded the windows version of PHP v5.3.28 and used the non-thread type.  I extracted it to C:\PHP.  I renamed the php.ini-production file to php.ini.  I set the path in EW4 to C:\PHP\php-cgi.exe (it was there this time). 

    I created a page with only

    <?php
    phpinfo();
    ?>

    and it does preview showing me a lot of information about php 5.3.28.

    I then tried to preview a page that is working on the website and the page is blank.  I tried this with Firefox v31 and IE v11. 

    The main reason I want to be able to preview them first is because I am working on some forms and I don't want them to "go live" until I am sure they are working correctly.  From my understanding, that is what this is all about.

    Did I do something wrong?  Do you have any other suggestions?

    I am using Windows 8.1 Pro with Media Center 64-bit.  Does that make a difference?


    mjmart61



    • Edited by mjmart61 Thursday, July 31, 2014 3:03 PM added OS
    Thursday, July 31, 2014 2:58 PM
  • If PHPinfo ran, then PHP is installed, EW is finding the exe, the PHP pages are being previewed by the development server, and there is nothing else related to EW that needs fixing.

    I'm sorry, but there is no way to know why your form PHP page is not previewing, but it's related to the page, maybe to resources it is using that are on the site but are not local, or who knows what else, but not to EW's setup.



    • Edited by KathyW2 Thursday, July 31, 2014 5:49 PM
    • Marked as answer by mjmart61 Thursday, July 31, 2014 8:03 PM
    Thursday, July 31, 2014 5:47 PM
  • OK.  I understand what you are saying.  Thank you for all your help. 

    I really wish this would work for me.  I might have to find something else to use now.

    Have a great day.


    mjmart61

    Thursday, July 31, 2014 8:03 PM
  • mjmart61. if EW won't work for you for previewing PHP files, then you're going yo be seriously SOL with anything else. EW is the ONLY Webdev app that comes with a built-in development server that serves PHP pages. Any other app will require you to install a server stack supporting PHP on your machine. What Kathy is telling you is that if phpinfo is correctly displaying on your system, then the problem is not with EW, but with your actual code, and that will be true not matter which app you use for development.

    Bottom line: You must correct the issues with your PHP code instead of blaming EW.  ;-)

    cheers,
    scott


    Please remember to "Mark as Answer" the responses that resolved your issue. It is common courtesy to recognize those who have helped you, and it also makes it easier for visitors to find the resolution later.

    Thursday, July 31, 2014 8:32 PM
  • I think I understand, Scott.

    You and Kathy are basically saying that there must be something on the production machine that I don't have that EW4 doesn't account for, (or possibly doens't need since other users of EW4 can preview PHP), since everything works fine on the production machine - and my machine can preview the phpinfo via the EW4 preview - right?


    mjmart61

    Thursday, July 31, 2014 8:43 PM
  • Correct. The fact that the phpinfo page is displaying as expected indicates that there is nothing wrong with your PHP installation, and that EW's development server is launching, processing the PHP in the page, and rendering the resulting HTML out to the browser. So, basically, the only element that is not working as expected is the test page that you are trying to render.

    This could mean that you have one or more include files that are available on the production machine but that are not available locally, or that you have database connections that are valid on the production machine but not locally, or any of a number of other issues.

    The point is, even if you installed an *AMP stack to  create an instance of Apache, and tried to test using another dev package that doesn't have its own dev server like EW, you would face the same issues. The problem, clearly, is not with the server or with PHP, since both are working if you are able to view the phpinfo page, but with the page that you are trying to test locally. Have you thoroughly reviewed the PHP code of the test page to determine if there are any resources accessed from local relative paths that are available remotely but not locally?

    cheers,
    scot


    Please remember to "Mark as Answer" the responses that resolved your issue. It is common courtesy to recognize those who have helped you, and it also makes it easier for visitors to find the resolution later.

    • Marked as answer by mjmart61 Thursday, July 31, 2014 10:09 PM
    Thursday, July 31, 2014 9:45 PM
  • Some of the pages do require a login that is connected to a MySQL database that is only on the production server, but others do not.  Neither are previewing. 

    I'm not seeing anything that is available remotely but not locally. but I'm going to comment out some sections to see if I missed something. 

    I guess I have some work ahead of me.  :)

    Thank you so much for all your help and helping me to understand.


    mjmart61

    Thursday, July 31, 2014 10:09 PM
  • If you have a *small* php page that is not previewing in EW, you could post the markup here and let us see what is in it.
    Friday, August 1, 2014 12:56 AM
  • I thought of that and just might do that.  I'm going to try some things first.  I will let you know.

    mjmart61

    Friday, August 1, 2014 2:04 PM
  • Yes, do that if you can't find the answer. (Usually we discourage people from posting markup, since a link to the live page gives us all the information we need, but in the case of server-side scripting, such as PHP, a link to the page won't show us what's going on.)
    • Edited by KathyW2 Friday, August 1, 2014 2:20 PM
    Friday, August 1, 2014 2:20 PM
  • One more thing: If you have any html pages that link to your php pages, make sure your site settings in EW are set to preview *all* pages with the development server. Otherwise, if you start from an html page then link to a PHP page, you won't be using the server, just opening the page from the file system, and PHP of course won't run. This won't explain why a page opened directly for preview wouldn't work (the development server would fire up), but it would explain why a page reached after initially opening an HTML page wouldn't work (it's all the browser and the file system at that point, no server).  So, for sites with mixed types of pages, preview all of them using the development server so when you navigate starting from an HTML page, your PHP and Asp.Net pages will work.
    • Edited by KathyW2 Friday, August 1, 2014 2:27 PM
    Friday, August 1, 2014 2:26 PM
  • I didn't have that set but just changed it and I get the same results.  My pages are a mix of php and html.  I think there might be an outside call but I haven't had a chance to test that yet. 

    Of course, it's not the only thing I'm working on these days.  :)


    mjmart61

    Friday, August 1, 2014 2:34 PM
  • To be clear, I wasn't talking about an individual page being a mix of php and html (PHP pages frequently include HTML sections), but of the site containing both pure HTML pages (page.htm) and pages containing PHP (page.php).

    Regardless, if you've changed the setting and getting the same results, that wasn't your issue.

    Friday, August 1, 2014 2:51 PM
  • I just tried our feedback page and commented out all of the php code.  Still won't preview. 

    How do I post the markup?  The page I have been trying to preview is 585 lines of code.  Is that too long to post here?


    mjmart61

    Friday, August 1, 2014 2:58 PM
  • When you reply, look at the top of the reply box where you will see formatting icons. B, I, etc. The symbol next to "HTML" is the code block icon. Click that, and paste your code into it.

    Is 585 lines of code the shortest example page you have that won't preview?   If so... oh well, try it.


    • Edited by KathyW2 Friday, August 1, 2014 3:35 PM
    Friday, August 1, 2014 3:33 PM
  • Thank you.  I see that now.  I will try to post something later.  I will try to find a smaller page.

    mjmart61

    Friday, August 1, 2014 4:01 PM
  • I found a much smaller page that is called news.php.  It is in the root of the website.  It is not previewing either.

    Here is the code:

    <?php
    define('QUADODO_IN_SYSTEM', true);
    require_once('login/includes/menu.php');
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
    
    <head>
    <title>News - Summit Traffic</title>
    <meta content="Find out news about Summit Traffic.  We will post new about our web changes, press releases, etc.  Check back often to see what is new!" name="description" />
    <meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type" />
    <meta content="text/css" http-equiv="Content-Style-Type" />
    <meta content="IE=EmulateIE7" http-equiv="X-UA-Compatible" />
    <meta content="Summit Traffic, News, Web changes, Press release, NAB" name="keywords" />
    <meta content="English" lang="en" name="language" />
    <style type="text/css">
    .center {
    	text-align: center;
    }
    </style>
    </head>
    
    <body>
    
    <?php include_once('login/includes/analyticstracking.php') ?>
    <h1 class="center">News about Summit Traffic!</h1>
    <h2>Web Changes</h2>
    <p><img alt="New!" height="22" src="images/small_new.gif" width="35" />This is where 
    we&#39;ll announce the most recent additions to our web site. If you&#39;ve visited 
    us before and want to know what&#39;s changed, take a look
    <a href="News/web_changes.php">here</a> first. </p>
    <hr />
    <h2>Other News</h2>
    <ul>
    	<li>03/22/2011 -- <a href="News/NAB.php">NAB Show 2011</a></li>
    	<li>04/08/2010 -- <a href="News/NAB.php">NAB Show 2010</a></li>
    	<li>08/12/2009 -- <a href="News/new_web.php">Summit Traffic&#39;s New Website</a>
    	</li>
    	<li>03/05/2009 -- <a href="News/NAB.php">NAB Show 2009</a> </li>
    	<li>12/27/2005 -- <a href="News/new_partners.php">Summit Software Systems, Inc. 
    	and Pristine Systems become partners</a> </li>
    </ul>
    
    </body>
    
    </html>
    <?php
    require_once('login/includes/footer.php'); 
    ?>

    Thank you.


    mjmart61

    Friday, August 1, 2014 4:38 PM
  • The php in that page requires includes I don't have.  For me, of course, it throws an error because the "require" or "require_once" throws a fatal error and stops script processing if the include isn't found.

    If you switch the "require_once" to "include", the page displays the HTML, but with warnings about all the include files it can't find.  See if you get any.  When things are working you can switch it back.

    Switch the "require" and "require_once" to "include" in any nested includes, too, for testing.





    • Edited by KathyW2 Friday, August 1, 2014 6:41 PM
    Friday, August 1, 2014 6:15 PM
  • I took out all the php code and the page previewed.  I added in the include for the footer and it did preview.  I added back in the php code for the google analytics and it did preview.  I added in the include for the menu.php file and it did not preview.  I changed the path for the menu.php and it returned an error.  So, it seems to me that it is something in my menu.php file that is causing things to not preview.  Getting closer.

    The menu.php page is over 200 lines.  I'm going to try to see if I can narrow it down first. 

    Thank you so much for your help. 


    mjmart61

    Friday, August 1, 2014 9:09 PM
  • I have narrowed it down to the PHP code in the top section of my menu.php page that is being called by the news.php page. I put new comments about previewing to start with // *****.  I know you won't have those files.  I just want to be sure it isn't how they are being called.

    <!-- FreeFind Begin No Index -->
    <?php
    /*** *** *** *** *** ***
    * @package Quadodo Login Script
    * @file    menu.php
    * @start   July 25th, 2007
    * @author  Douglas Rennehan
    * @license http://www.opensource.org/licenses/gpl-license.php
    * @version 1.0.3
    * @link    http://www.quadodo.net
    *** *** *** *** *** ***
    * This program is free software; you can redistribute it and/or modify
    * it under the terms of the GNU General Public License as published by
    * the Free Software Foundation; either version 2 of the License, or
    * (at your option) any later version.
    *
    * This program is distributed in the hope that it will be useful,
    * but WITHOUT ANY WARRANTY; without even the implied warranty of
    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    * GNU General Public License for more details.
    *
    * You should have received a copy of the GNU General Public License
    * along with this program; if not, write to the Free Software
    * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    *** *** *** *** *** ***
    * Comments are always before the code they are commenting.
    *** *** *** *** *** ***/
    // *****I have to comment out the three lines below when previewing*****
    if (!defined('QUADODO_IN_SYSTEM')) {
    exit;
    }
    // Report everything except E_NOTICE, because it screws a lot of stuff up...
    error_reporting(E_ALL ^ E_NOTICE);
    // *****The three lines below were already being commented out*****
    // Send some headers
    // session_start();
    // header('Content-Type: text/html; charset=iso-8859-1');
    // The language we are using
    // *****I have to comment out the line below when previewing*****
    require_once('Blank.lang.php');
    // The qls class will start the other classes
    // *****I have to comment out the two lines below when previewing*****
    require_once('qls.class.php');
    $qls = new qls(SYS_CURRENT_LANG);
    ?>
    


    mjmart61

    Friday, August 1, 2014 9:42 PM
  • First, change "require_once" to "include" so you can see what errors there are in finding the files in those last two, if you haven't already done that.

    Beyond that, I can't tell you why, if you defined 'QUADODO_IN_SYSTEM' as true that it doesn't test as true - if that line is indeed where the error happens.

    Do any of these files contact a database?  That won't work locally unless you've got a copy of the database locally, and a local connection string defined to replace the live site one.

    Friday, August 1, 2014 11:51 PM
  • I did do that with the include and it didn't make any difference. The pages I'm trying to preview now are not on the side that requires login but I suppose it might still be looking at the database that is only online. I will check that out on Monday. Thanks you all for everything so far. Have a great weekend.

    mjmart61

    Saturday, August 2, 2014 1:13 AM
  • You know, after reading again the first part of this thread, it occurs to me that maybe we're coming at this from the wrong angle. It seems to me that the original objective here was not to troubleshoot the PHP, but to determine why what runs just fine remotely doesn't run locally, so that you can test those pages before publishing. Right?

    Well, then, let's rethink this whole thing. The actual objective is to test before publishing, not necessarily to get the pages to run locally. I thought back to the time when I used to use Dreamweaver, which doesn't have a built-in development server. I used to routinely test Classic ASP pages on the target server, simply renaming them with nonsense names. As long as they are not linked anywhere in the live site, they essentially don't exist to the outside world.

    So, mjmart61, since you know those pages work on the live server, why don't you simply do your edits locally, then name the page xgprlhg.html (or something) and publish it to test it. Then, when the page checks out, rename it to the target live name (so that EW updates any links to it in the local site), then publish it again.

    Granted, you don't get the satisfaction of figuring out why those pages break locally, but that's not really what you're getting paid for, is it? You get your pages edited, tested, and published, and leave the mystery of why they don't run locally to someone with "PHP code debugging" in their job description, n'est-ce pas?  ;-)

    cheers,
    scott

    Please remember to "Mark as Answer" the responses that resolved your issue. It is common courtesy to recognize those who have helped you, and it also makes it easier for visitors to find the resolution later.

    Monday, August 4, 2014 3:43 AM
  • Yes, the final objective is to be able to test the pages before publishing.  I was hoping to not have to rename all the pages just to test them.  It might come down to that though.

    First, I wanted to be sure that I had PHP installed correctly. Accomplished. Thank you.

    Second, I wanted to be sure that the development server is working.  Accomplished.  Thank you.

    Third, I want to be able to preview my pages.  Not accomplished.

    Why my pages aren't previewing was a mystery but I think we have narrowed that down.  I thank you all for your help, thoughts, etc.

    I can probably take it from here and post back if I do need more assistance.


    mjmart61

    Monday, August 4, 2014 2:27 PM
  • Yes, the final objective is to be able to test the pages before publishing.  I was hoping to not have to rename all the pages just to test them.  It might come down to that though.

    First, I wanted to be sure that I had PHP installed correctly. Accomplished. Thank you.

    Second, I wanted to be sure that the development server is working.  Accomplished.  Thank you.

    Third, I want to be able to preview my pages.  Not accomplished.

    Why my pages aren't previewing was a mystery but I think we have narrowed that down.  I thank you all for your help, thoughts, etc.

    I can probably take it from here and post back if I do need more assistance.


    mjmart61


    Third objective is accomplished now too.  I'm not sure exactly what I changed to get it to work but all php  pages are previewing locally as expected now.  I thank you KathyW2 and paladyn for all your help.  I really appreicate it all.

    mjmart61

    Wednesday, August 27, 2014 8:06 PM