Forum Moderators: coopster

Message Too Old, No Replies

PHP Includes in Dreamweaver MX

         

alphatekllc

10:39 pm on Jul 30, 2006 (gmt 0)

10+ Year Member



I have a question about using PHP includes in Dreamweaver MX. I have used includes in Dreamweaver versions previous to MX and have had no problems viewing them in Dreamweaver or in a browser afterward. They look and work fine.

Since switching over to Dreamweaver MX, however, I cannot edit pages with PHP includes in them, using MX. I have to open them up in an older version of Dreamweaver because they don't display correctly in the newer version.

I even tried inserting the code for the include using Dreamweaver's "Insert" menu.

Here's what happens: I insert the include tag and then specify the PHP page to be included. If I put quotes around the name of the include file, such as "ad1.php", the page immediately gets all messed up while viewing it in Dreamweaver MX. It displays correctly in a browser and in older versions of Dreamweaver, but not in MX.

If I remove the quotes from around the filename in the include tag, it displays correctly in MX, but when I upload it and view it in a browser, it generates the following error:

Warning: main(ad1php): failed to open stream: No such file or directory in /home/sriba/public_html/index1.php on line 89

I make no claims to being a programmer or an expert in any of this, so this has me somewhat baffled and frustrated. I'd really like to be able to edit these pages using MX so I can take advantage of it's newer features, etc.

Does anybody have any input for me on this one?

Thank You in advance.

omoutop

5:55 am on Jul 31, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



well you can try to have the include in its own php tags

<?php //some php code?>
<? include("path/to/some_file.php");?>
<? // some more php code?>

This work fine with me.

alphatekllc

2:46 pm on Jul 31, 2006 (gmt 0)

10+ Year Member



Thanks for your response, but I'm not sure what I should put in the first and last line?

<?php //what php code?>
<? include("ad1.php");?>
<? // what other php code?>

Can you give me a little more help with this?

Thanks again.

ryan_b83

3:00 pm on Jul 31, 2006 (gmt 0)

10+ Year Member



the first and last line would just be PHP code. If you are not a programmer it would be nothing. as a minimum it would be this

<?php
include("path/to/some_file.php");
?>

alphatekllc

4:10 pm on Jul 31, 2006 (gmt 0)

10+ Year Member



Thanks, I understand the <?php
include("path/to/some_file.php");
?> part of it, but it's the quotes that seem to cause the problem with Dreamweaver MX.

The other person who responded mentioned a couple other lines of PHP code to try, but I'm not quite sure what should be in those lines of code.

Angelis

4:26 pm on Jul 31, 2006 (gmt 0)

10+ Year Member



It depends on the content of the include.

Try

<?php include "file.ext";?>
or
<?php include 'file.ext';?>
or
<?php include ("file.ext");?>
or
<?php include ('file.ext');?>

it depends on the content of the file.

alphatekllc

1:04 am on Aug 3, 2006 (gmt 0)

10+ Year Member



Thanks a bunch! This one worked: <?php include "ad1.php";?>

Still displays properly in Dreamweaver MX and pulls the include file in a browser with no errors or viewing problems.

Thanks again :-)

Angelis

8:50 am on Aug 4, 2006 (gmt 0)

10+ Year Member



No probs happy to help