Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Dreamweaver not recognizing PHP code

Participant ,
Jun 11, 2021 Jun 11, 2021

 

Screenshot-1.jpgexpand image

 

2.8K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Participant , Jun 13, 2021 Jun 13, 2021

Thank you all for your assistance!  I went ahead and reached out to a PHP expert and they were able to help me get this resolved.  Turns out something was going on with my configurations in XAMPP.  So for anyone who finds this post in the future and is having the same issues, check your PHP local drive configurations as well!

Translate
Participant ,
Jun 11, 2021 Jun 11, 2021

I am not sure why Adobe only posted the picture, but here is the explanation I wrote out to go with the picture.  My apologies for the confusing:
Hello,

I used a PHP shortcode -  <?php include "./cr-nav-3.php";?>  - for every page of my site that I wanted the menu displayed on.  However, now Dreamweaver is no longer recognizing my PHP tags for my menu. 

 

When I upload the files to my server, everything renders fine.  However, in Dreamweaver, my menu does not display.  My CSS styles come from my menu as well so the layout looks funky.

 

I retyped the shortcode and my menus came up and I thought everything was resolved.  But as soon as I closed DW down and re-opened, the styles were gone.  Now when I retype/re-insert the PHP code, nothing happens.  Everything has worked up until about a couple of months ago when I noticed this.

 

I read that PHP shortcodes have to be "enabled".  I am still very much a PHP novice, only knowing enough to do what I need to be done.  So I don't even know where to look to "enable" these tags if that is the issue.

 

Thank you!

 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 11, 2021 Jun 11, 2021

Which local testing server do you have?

 

Is it running and is it defined in DW?

 

Does your local site folder reside inside the local testing server's default web directory (see screenshots)?

 

Local Site in Local Testing ServerLocal Site in Local Testing Serverexpand image

 

Add Testing ServerAdd Testing Serverexpand image

 

LocalhostLocalhostexpand image

 

Server modelServer modelexpand image

 

Final screenFinal screenexpand image

 

 

Nancy O'Shea— Product User, Community Expert & Moderator
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jun 11, 2021 Jun 11, 2021

Hi Nancy,

My styles are on an external sheet in my navigation menu.  Since I am linking the same menu to several pages (via PHP), the external sheet on my Navigation page affects whatever page I place the PHP shortcode on.  

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 11, 2021 Jun 11, 2021

PHP includes express the same code that would normally appear inside a static web page and in proper document order. The PHP include file for your sitewide navigation menu (in your case cr-nav-3.php) should contain ONLY the releveant menu code and nothing more.  Ditto for the <header> and <footer> includes.

 

Please show us the code contained in your include file cr-nav3.php.

 

Also, you didn't answer my question about your local testing server.  Do you have one set-up?

 

Nancy O'Shea— Product User, Community Expert & Moderator
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jun 11, 2021 Jun 11, 2021

My menu styles are on the same external sheet as everything else, this is why we just used the php-short code since it was the same external sheet. This issue just started a couple of months ago.

I am using XAMPP.  

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 11, 2021 Jun 11, 2021

Based on your replies so far, I don't think you're using PHP includes properly. 

That said, I would need to see what's contained in your include file (cr-nav-3.php) to comment further.

 

 

 

 

Nancy O'Shea— Product User, Community Expert & Moderator
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 11, 2021 Jun 11, 2021

This comment concerns me.

 

"My CSS styles come from my menu as well so the layout looks funky."

 

Why would you put CSS <styles> inside your navigation include?  CSS belongs in an external stylesheet, a separate physical file to which all your parent documents are linked inside the <head> tag.

 

For example:

 

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Bootstrap 4.5 Starter with PHP Includes</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">

<!--Bootstrap 4.5 on CDN-->
<link rel="stylesheet" href="
https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">

<!--Custom CSS-->
<link rel="stylesheet" href="css/my_styles.css">
</head>

<body>
<!--sitewide header-->
<header><?php require_once('Includes/header.html');?></header>

<!--sitewide navigation-->
<nav><?php require_once('Includes/menu.html');?></nav>

<main>
<h1>Bootstrap Starter with PHP Inludes</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Veritatis quos, illo molestiae dolore, nostrum a dolores possimus alias suscipit nam sapiente incidunt atque, maiores labore vitae. Et, quasi. Eius, eos.</p>
</main>

<!--sitewide footer-->
<footer><?php require_once('Includes/footer.html');?></footer>

<!--Supporting scripts: first jQuery, then popper, then Bootstrap JS, etc...--> 
<script src="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script> 
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="js/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script>
</body>
</html>

 

 

Nancy O'Shea— Product User, Community Expert & Moderator
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 11, 2021 Jun 11, 2021

Older versions of Dreamweaver always preferred/recognised include/require code written with brackets (even though brackets are not required and  the preferred way is not to have them), for example like this:

 

<?php include("somefile.php"); ?>

 

I don't know if this has changed in newer versions of Dreamweaver, try it and see if it makes any difference (try with single quotes if double quotes don't work).

 

Paul-M - Community Expert
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 11, 2021 Jun 11, 2021

Parentheses ( ) are not required but the dot slash prefix may be a problem locally.

 

Try this instead of what you have now:

<?php include "credit-report/cr-nav-3.php";?>

 

Nancy O'Shea— Product User, Community Expert & Moderator
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 11, 2021 Jun 11, 2021

If this about what works in Dreamweaver and as I already said Parentheses (brackets) are not required in PHP in this case - however I'm pretty sure older versions of Dreamweaver prefer include/require written with brackets and  if you use insert/require from Dreamweavers insert bar => PHP tab it still includes brakcets in the the code (hint)... so try it and see if it works

Paul-M - Community Expert
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 12, 2021 Jun 12, 2021
quote

I'm pretty sure older versions of Dreamweaver prefer include/require written with bracket...

===========

That may be true but I no longer use CS6 and I don't think the OP is either.  The screenshot at the top looks like a recent version of DW CC.

 

Not meaning to be pedantic but on this side of the pond we differentiate between:

  • parentheses ( ) -- sometimes called curved brackets in UK,
  • brackets [ ] -- or straight brackets,
  • and curly brackets { }. 

As most coders know, they are not interchangeable. 

 

Nancy O'Shea— Product User, Community Expert & Moderator
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 12, 2021 Jun 12, 2021
quote
quote

I'm pretty sure older versions of Dreamweaver prefer include/require written with bracket...

===========

That may be true but I no longer use CS6 and I don't think the OP is either.  The screenshot at the top looks like a recent version of DW CC.

 

 

In Dreamweaver 2021 from the insert bar => PHP => includes - Dreamweaver still adds the parenthesis even though it's is not strictly the correct way...

 

In Dreamweaver 2021 PHP includes don't display the include files content  in Design View if written without parentheses (even though it is not strictly the correct way to write PHP includes) - if someone is in design view this may cause confusion, albeit Design View is old.

 

Oh no Nancy I would never expert you to be pedantic, condescending, rude, arrogant, belittling,  talk down to people etc etc etc ... You get the picture .... Maybe get  a life while you're at it as you spend far too much time on these forums trying to prove that you know more than everyone else and have bigger balls than them.....

Paul-M - Community Expert
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jun 13, 2021 Jun 13, 2021
LATEST

Thank you all for your assistance!  I went ahead and reached out to a PHP expert and they were able to help me get this resolved.  Turns out something was going on with my configurations in XAMPP.  So for anyone who finds this post in the future and is having the same issues, check your PHP local drive configurations as well!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines