Jump to content


Photo

PHP code not interpreted


  • Please log in to reply
7 replies to this topic

#1 cldeluna

cldeluna
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 12 March 2006 - 09:18 PM

Hi,

I am trying to display a report (set of returned data from a mysql backend). The site was made with Dreamweaver templates and other PHP code works but that is code that is called by the form. For this report I have php code in line since all it will do is display a report. It is witin the editable region of the HTML file.
Once I run the page and view source below is the excerpt I see in the view source window. Nothing displays on the form other than an empty table.

Obviously below I'm just tryint to get any php code interpreted. I've tested the SQL statement and the program outside the dreamweaver HTML file and it works.

Any suggestions?

Thanks in advance!

<td><!-- InstanceBeginEditable name="page_body" -->
<table width="200" border="1">
<tr>

<td>[!--coloro:#CC66CC--][span style=\"color:#CC66CC\"][!--/coloro--]<?php echo "Hello World"; ?>[!--colorc--][/span][!--/colorc--]</td>
<td> </td>
<td> </td>
</tr>
</table>
[!--coloro:#CC66CC--][span style=\"color:#CC66CC\"][!--/coloro--]<?php
$chapterTitle = 'PHP Syntax';
$message = "The chapter you are currently reading is $chapterTitle";
echo $message;
?>[!--colorc--][/span][!--/colorc--]

<p> </p>
<p> </p>
<!-- InstanceEndEditable -->

#2 moberemk

moberemk
  • Members
  • PipPipPip
  • Advanced Member
  • 695 posts

Posted 12 March 2006 - 11:11 PM

Unless the code is an include file, Dreamweaver-generated, or extension-generated, Dreamweaver won't show it in any helpful way, just as a block of PHP code.
Disclaimer: No matter how harsh I may be, I'm always IMO only.

#3 cldeluna

cldeluna
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 13 March 2006 - 01:43 AM

[!--quoteo(post=354344:date=Mar 12 2006, 05:11 PM:name=moberemk)--][div class=\'quotetop\']QUOTE(moberemk @ Mar 12 2006, 05:11 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Unless the code is an include file, Dreamweaver-generated, or extension-generated, Dreamweaver won't show it in any helpful way, just as a block of PHP code.
[/quote]

I've tried using both methods, that is basically all the code within the HTML file and an include file

<?php include (./includes/view_user.php) ?>

Neither method actually executes the code. It't almost like it a comment.

#4 sgb162

sgb162
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 13 March 2006 - 02:23 AM

If you're looking to test PHP files offline, I think your best bet is to download and install apache. <_<

#5 cldeluna

cldeluna
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 13 March 2006 - 02:28 AM

[!--quoteo(post=354382:date=Mar 12 2006, 08:23 PM:name=sgb162)--][div class=\'quotetop\']QUOTE(sgb162 @ Mar 12 2006, 08:23 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
If you're looking to test PHP files offline, I think your best bet is to download and install apache. <_<
[/quote]

I have both Apache and PHP installed and running. The PHP file on it's own works just fine. It's when I either include it into the Dreamweaver HTML file (based on a template) either directly or via an include file that it is not interpreted.

So the commands in a PHP file I call directly work, imbedded (or included via the include statement) within the HTLM file is not interpreted. When I view source I see basically either the code or the include statement. See example from my first posting.

Thanks!

#6 sgb162

sgb162
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 13 March 2006 - 02:40 AM

For any PHP to run the file has to be saved as a .php file.

#7 moberemk

moberemk
  • Members
  • PipPipPip
  • Advanced Member
  • 695 posts

Posted 13 March 2006 - 12:22 PM

That seems obvious. What Dreamweaver version are you running?
Disclaimer: No matter how harsh I may be, I'm always IMO only.

#8 redbullmarky

redbullmarky
  • Staff Alumni
  • Advanced Member
  • 2,863 posts
  • LocationBedfordshire, England

Posted 13 March 2006 - 04:53 PM

[!--quoteo(post=354387:date=Mar 13 2006, 02:40 AM:name=sgb162)--][div class=\'quotetop\']QUOTE(sgb162 @ Mar 13 2006, 02:40 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
For any PHP to run the file has to be saved as a .php file.
[/quote]

whilst this is obvious, it's actually spot on - and unless something drastically wrong is going with your setup or your file naming, i'd run with this answer. i very much doubt that dreamweaver has anything to do with it - once the file is in the browser, dreamweaver has nothing to do with it.

if you have PHP set up, and it works for PHP files, then my guess is the files youre embedding PHP into are HTM/HTML files or similar, in which case the server wont even bother parsing them as php.
i kinda reckon that it's good practice to always use the same extensions throughout the site, even if a file uses no php in it at all.
"you have to keep pissing in the wind to learn how to keep your shoes dry..."

I say old chap, that is rather amusing!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users