Jump to content

Recommended Posts

I am trying to develop a browser interface for an embedded system.  The code written so far consists of one HTML page and one PHP script.  The HTML page creates a form containing a select widget and a submit button.  When the submit button is pressed, the selected item is posted to the PHP script for processing.  The PHP script does a MySQL query using the form data and generates HTML to display the query result in a table, which displays in a new Web page.  All of this works fine.  However...

 

I need to change the HTML page to create the select widget choices using a the result of a query run when the HTML page gets displayed.  I created a PHP script to do this, and included it in my HTML page in this manner:

 

<form action="procSomeForm.php" method="post">
    <?php
          include "genSelectList.php";
    ?>
   <input class="main" type="submit" name="submit[view]" value="View" style="width:70px"/>
</form>

 

When I tried this, the select didn't appear.  I tried moving the <select> </select> out of the PHP script and placing them around the "include".  The select now displayed but with no contents.  After many failed attempts to resolve any errors in the script, I began to suspect that the browser was ignoring the include directive.  I then reduced the problem to this trivial code:

 

<html>
<head>
<title>PHP Test</title>
</head>

<body>
    <?php
        include "tmp.php";
        echo "<p>This message brought to you by PHP!</p>";
    ?>

</body>
</html>

 

The PHP script looks like this:

 

<?php
echo "<p>Hello from tmp.php!</p>";
?>

 

My Web browser rendered the result as:

 

This message brought to you by PHP!

";?>

 

The "hello" message in tmp.php wasn't displayed, and the the browser printed the last few characters of the embedded PHP statement as if they were simple text!

 

I have tried this same experiment on two PCs with the same result.  My development PC runs Debian 6.0 (Squeeze) in VMWare on top of WinXP; I access the Web pages locally from within VMWare using IceWeasel.  My embedded PC also runs Debian 6.0; I access the Web pages  from my WinXP box using Firefox.  Interestingly, when I use IE8 to call up the trivial page from the embedded PC, it displays a blank page!

 

Sorry for the long-winded setup to the problem, but I wanted to point out that generating a separate HTML page from a PHP script works; it appears that the issue is with putting PHP statements in an HTML page.

 

Any help will be greatly appreciated - thanks in advance!

 

Chris

Personally to me sounds like something on your hosting server is misconfigured. I see no issue with the above coding you have mentioned, unless theres bits and pieces your failing to bring to light. who's your hosting provider?

I created a PHP script to do this, and included it in my HTML page in this manner:

<form action="procSomeForm.php" method="post">
    <?php
          include "genSelectList.php";
    ?>
   <input class="main" type="submit" name="submit[view]" value="View" style="width:70px"/>
</form>

Make sure that code is placed within a .php file. PHP code will not run within .html files.

Many thanks, Ken - you got it right!  I renamed my HTML file to .php, removed some boilerplate at the top generated by Bluefish when I created the page, and it now displays correctly.  I even re-enabled the call to the PHP script which generates the select contents, and that works, too!  BTW - I already had tried the method of adding an AddTYpe statement to httpd.conf, but it didn't help.  I'll look into this some more; if I can get this method working,  I'll add my result to this thread.

 

Thanks again, and to all for the prompt replies!

 

Chris

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.