Include/Require problems w. HTML

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
BigZ1981
New php-forum User
New php-forum User
Posts: 7
Joined: Sat Jul 19, 2014 11:24 pm

Sun Jul 20, 2014 3:49 pm

I would leave the ./ out of the filename as you don't need it: <?php include 'header.php'; ?>
I've never had an issue with anchor or image tags, so make sure you're closing tags that need to be closed & if you're adding other php code within that file, you check for any syntax errors. I had an issue with my contact form page not displaying, and I couldn't figure out why. I had to go through my code line by line to find out that I was missing a closed parentheses within one of my if statements. I had to read each line and statement to make sure I was closing everything properly. One small thing like that (which is hard to spot by just skimming through the code) will throw the whole thing off.

BigZ1981
New php-forum User
New php-forum User
Posts: 7
Joined: Sat Jul 19, 2014 11:24 pm

Sun Jul 20, 2014 9:45 pm

Yeah. Glad you figured it out. That include function is nifty...keeps you from having to change 50 million pages that have the same menu, title image, footers, etc. Heck, I even have an include within an include...which I probably don't need, but it helps me isolate the code I want to edit. For example...I have a similar include for headers.php & within that file I have an include for menu.php...now that I'm mentioning this, I may actually end up just putting my menu code in my headers.php file...it's not like it's a huge chunk of code in there anyway. Anyway, happy coding. :D

afelipeor
New php-forum User
New php-forum User
Posts: 10
Joined: Tue Apr 29, 2014 11:16 am

Wed Aug 27, 2014 8:18 am

Did you add the Files you want to include correctly in their directories? You could (and probably should) change their extensions to .php instead of leaving them in .html

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 7 guests