namednad Posted September 25, 2020 Share Posted September 25, 2020 (edited) Greetings to all! Newbie here, I just signed up this morning. I have an issue with a code I have been using for several years with multiple files/directories. Until recently all of the files have worked flawlessly. Now I have one file in a directory that does not display the text I which I am attempting to call up and it was working until recently. As stated above I have the same code in multiple directories and files and it works flawlessly in all files except for the one. I have spent a few hours attempting to remedy the situation with no success. I have looked at the source code for the errant file and that shows the text to be displayed but it is not displayed in any browser on several computers, whether Windows or Mac OSX. I even went so far as to delete the directory the file was in and re-uploaded the entire directory from a backup that is 2 or 3 years old, no change. I copied the entire coding from a working file with the same coding, deleted all the coding in the errant file and pasted the working coding into the errant file. - no change I have attached screen shots of the coding in errant file and one of many other files that work flawlessly with the php code that is involved highligted. Also attached are the browser page source files for the same errant and working files. The screen shots in order are errant file code, working file code, errant file source, and working file source. Every file with the same code as the errant one work flawlessly except for the errant one, and I have 11 files to be displayed on my website at https://TheLoveOfGod.org They are all listed under the Devotionals menu button except for one which is displayed on the home page. I have absolutely no training in web design, I am self taught. I began by hand typing html coding over 30 years ago and am now using Word Press with Elementor . I do not understand why this is happening. Can any of you offer assistance to resolve this. I thank you in advance for your assistance. Respectfully, dan Edited September 25, 2020 by namednad more explanation Quote Link to comment https://forums.phpfreaks.com/topic/311522-php-code-works-in-all-files-except-for-one/ Share on other sites More sharing options...
benanamen Posted September 25, 2020 Share Posted September 25, 2020 We cant paste pictures of code into our editors. Post real code using the code formatting tags. The <> icon. Quote Link to comment https://forums.phpfreaks.com/topic/311522-php-code-works-in-all-files-except-for-one/#findComment-1581567 Share on other sites More sharing options...
namednad Posted September 25, 2020 Author Share Posted September 25, 2020 Here is the coding that works in every file except for one. I've used it for several years to open html files in a php file by using julian date. I don't understand why it worked for years until recently in only one file yet still it works in all the other files I use it in. <div id="devotional"><?php include ( date("z") . ".html" ); ?></div> Quote Link to comment https://forums.phpfreaks.com/topic/311522-php-code-works-in-all-files-except-for-one/#findComment-1581568 Share on other sites More sharing options...
benanamen Posted September 25, 2020 Share Posted September 25, 2020 Does the file exist where you are calling it from? Turn on error reporting. What is the error message? I suspect the error message will be Warning: include(xxx.html): failed to open stream: No such file or directory in path Quote Link to comment https://forums.phpfreaks.com/topic/311522-php-code-works-in-all-files-except-for-one/#findComment-1581569 Share on other sites More sharing options...
namednad Posted September 25, 2020 Author Share Posted September 25, 2020 No error message, the page does open without displaying the text in the file. Quote Link to comment https://forums.phpfreaks.com/topic/311522-php-code-works-in-all-files-except-for-one/#findComment-1581572 Share on other sites More sharing options...
namednad Posted September 25, 2020 Author Share Posted September 25, 2020 The page source in my browser for the errant file shows the text is there, it simply is not displayed like it is with the working files. Quote Link to comment https://forums.phpfreaks.com/topic/311522-php-code-works-in-all-files-except-for-one/#findComment-1581573 Share on other sites More sharing options...
benanamen Posted September 25, 2020 Share Posted September 25, 2020 We cant see the page source of your browser. Post it here. Quote Link to comment https://forums.phpfreaks.com/topic/311522-php-code-works-in-all-files-except-for-one/#findComment-1581574 Share on other sites More sharing options...
namednad Posted September 25, 2020 Author Share Posted September 25, 2020 Here is the errant file source image Quote Link to comment https://forums.phpfreaks.com/topic/311522-php-code-works-in-all-files-except-for-one/#findComment-1581575 Share on other sites More sharing options...
namednad Posted September 25, 2020 Author Share Posted September 25, 2020 I just noticed that the screen shot of old file page source image I sent when I started this post originally was only partial. Here is the complete page source file image. Quote Link to comment https://forums.phpfreaks.com/topic/311522-php-code-works-in-all-files-except-for-one/#findComment-1581576 Share on other sites More sharing options...
benanamen Posted September 25, 2020 Share Posted September 25, 2020 STOP posting pictures! I already told you to post code. Quote Link to comment https://forums.phpfreaks.com/topic/311522-php-code-works-in-all-files-except-for-one/#findComment-1581579 Share on other sites More sharing options...
namednad Posted September 25, 2020 Author Share Posted September 25, 2020 (edited) Apologies, I'm used to sending screenshots. I had to leave the desk for a while to go pickup a prescription. -------------------------- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link REL="SHORTCUT ICON" HREF="/tlog-icon.ico" type="image/x-icon"><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script type="text/javascript"> BLB.Tagger.Translation = 'KJV'; BLB.Tagger.HyperLinks = 'all'; // 'all', 'none', 'hover' BLB.Tagger.HideTanslationAbbrev = false; BLB.Tagger.TargetNewWindow = true; BLB.Tagger.Style = 'par'; // 'line' or 'par' BLB.Tagger.NoSearchTagNames = ''; // HTML element list BLB.Tagger.NoSearchClassNames = 'noTag doNotTag'; // CSS class list </script> <style type="text/css"> body { font-family: LeagueGothic, Arial, Helvetica, sans-serif; font-color: 888888; } </style> <script src="https://www.blueletterbible.org/assets/scripts/blbToolTip/BLB_ScriptTagger-min.js" type="text/javascript"></script> <title>Today's Daily Light On The Daily Path</title> </head> <body> <center><h3>This Evening's Reading of Daily Light On The Daily Path</h3> <h4>Prepared by Jonathan Bagster and other members of his family</h4> <h4><a href="https://www.theloveofgod.org/devotionals/DailyLight/Morn/index.php">Go to This Morning's Reading</a></h4> <h6><em>Move your mouse over the verse reference to read the entire verse in NKJV version which is written in modern english.</em> </h6></center> <div id="devotional"><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <script src="https://www.blueletterbible.org/assets/scripts/blbToolTip/BLB_ScriptTagger-min.js" type= <title>Untitled Document</title> </head> <body> <p> Yea, hath God said? Gen. 3:1<br> <br> When the tempter came to Jesus, he said, If thou be the Son of God. Matt. 4:3<br> <br> Jesus said unto him, It is written.... it is written... it is written. Matt. 4:4, 7, 10<br> <br> Then the devil leaveth him. Matt. 4:11<br> <br> I may not return with thee. For it was said to me by the word of the LORD, Thou shalt eat no bread nor drink water there. He said unto him, I am a prophet also as thou art; and an angel spake unto me by the word of the LORD, saying, Bring him back with thee into thine house, that he may eat bread and drink water. But he lied unto him. So he went back with him. The man of God.... was disobedient unto the word of the LORD: therefore the LORD hath delivered him unto the lion, which hath torn him, and slain him, according to the word of the LORD. I Kings 13:16-19 & 26<br> <br> Though we, or an angel from heaven, preach any other gospel unto you than that which we have preached unto you, let him be accursed. Gal. 1:8<br> <br> Thy word have I hid in mine heart, that I might not sin against thee. Psa. 119:11 </p> </body> </html> </div> </body> </html> Edited September 25, 2020 by Barand Add code tags Quote Link to comment https://forums.phpfreaks.com/topic/311522-php-code-works-in-all-files-except-for-one/#findComment-1581580 Share on other sites More sharing options...
Barand Posted September 25, 2020 Share Posted September 25, 2020 (edited) 6 hours ago, benanamen said: Post real code using the code formatting tags. The <> icon. I've added the tags for you - this time. Next time, use the "code" icon Edited September 25, 2020 by Barand Add image Quote Link to comment https://forums.phpfreaks.com/topic/311522-php-code-works-in-all-files-except-for-one/#findComment-1581581 Share on other sites More sharing options...
namednad Posted September 26, 2020 Author Share Posted September 26, 2020 Thank you Barand for your effort but I'm afraid you corrected the wrong code which is actually the page source from the browser of the non-working webpage and not the html file of the webpage. To see the error I'm dealing with, in your browser, open https://www.theloveofgod.org/devotionals/DailyLight/Morn/index.php then click on the link "Go to This Evening's Reading" and you will see the web page without the text. You can see the text is in the page source file if you view the page source file . You were looking at the resulting page source file. The actual html file code is shown below this, and the php code highlighted in red near the bottom of the file doesn't work on this php file only out of 11 files with the same code. The html file does open and display the webpage in the browser without the text from the html file . The page source file is what your corrected and it does show the text that is not displayed in the browser when the page is opened. Here is an excerpt from the page source file of the browser which you corrected showing the text that is not displayed when the web page is opened:<title>Untitled Document</title> </head> <body> <p> Yea, hath God said? Gen. 3:1 <br> <br> When the tempter came to Jesus, he said, If thou be the Son of God. Matt. 4:3 <br> <br> Jesus said unto him, It is written.... it is written... it is written. Matt. 4:4, 7, 10 <br> <br> Then the devil leaveth him. Matt. 4:11 <br> <br> I may not return with thee. For it was said to me by the word of the LORD, Thou shalt eat no bread nor drink water there. He said unto him, I am a prophet also as thou art; and an angel spake unto me by the word of the LORD, saying, Bring him back with thee into thine house, that he may eat bread and drink water. But he lied unto him. So he went back with him. The man of God.... was disobedient unto the word of the LORD: therefore the LORD hath delivered him unto the lion, which hath torn him, and slain him, according to the word of the LORD. I Kings 13:16-19 & 26 <br> <br> Though we, or an angel from heaven, preach any other gospel unto you than that which we have preached unto you, let him be accursed. Gal. 1:8 <br> <br> Thy word have I hid in mine heart, that I might not sin against thee. Psa. 119:11 </p> </body> </html> </div> </body> </html> --------------------------------------------------------------- Here is the code of the actual html file in which the php code does not work although it works in the other 10 files with the same php code. Until recently it worked with this file and without being changed it no longer works: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link REL="SHORTCUT ICON" HREF="/tlog-icon.ico" type="image/x-icon"><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script type="text/javascript"> BLB.Tagger.Translation = 'KJV'; BLB.Tagger.HyperLinks = 'all'; // 'all', 'none', 'hover' BLB.Tagger.HideTanslationAbbrev = false; BLB.Tagger.TargetNewWindow = true; BLB.Tagger.Style = 'par'; // 'line' or 'par' BLB.Tagger.NoSearchTagNames = ''; // HTML element list BLB.Tagger.NoSearchClassNames = 'noTag doNotTag'; // CSS class list </script> <style type="text/css"> body { font-family: LeagueGothic, Arial, Helvetica, sans-serif; font-color: 888888; } </style> <script src="https://www.blueletterbible.org/assets/scripts/blbToolTip/BLB_ScriptTagger-min.js" type="text/javascript"></script> <title>Today's Daily Light On The Daily Path</title> </head> <body> <center><h3>This Evening's Reading of Daily Light On The Daily Path</h3> <h4>Prepared by Jonathan Bagster and other members of his family</h4> <h4><a href="https://www.theloveofgod.org/devotionals/DailyLight/Morn/index.php">Go to This Morning's Reading</a></h4> <h6><em>Move your mouse over the verse reference to read the entire verse in NKJV version which is written in modern english.</em> </h6></center><div id="devotional"><?php include ( date("z") . ".html" ); ?></div> <?php error_reporting(E_ALL); ?> </body> </html> --------------------------------------------- Thank you again! Respectfully, dan Quote Link to comment https://forums.phpfreaks.com/topic/311522-php-code-works-in-all-files-except-for-one/#findComment-1581582 Share on other sites More sharing options...
kicken Posted September 26, 2020 Share Posted September 26, 2020 3 hours ago, namednad said: <div id="devotional"><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <script src="https://www.blueletterbible.org/assets/scripts/blbToolTip/BLB_ScriptTagger-min.js" type= <title>Untitled Document</title> </head> Notice how after your devotional div you have another DOCTYPE and begining of an HTML document? That's not correct. The doctype and all that stuff in the <head> should only ever appear once in a page. Your include file apparently has another copy of it that you need to remove. This appears to be a problem not only in the file that doesn't display, but also in your other files that do work. All the .html files you're including as content into the page should contain only the HTML content to be displayed and not all the other page structure (doctype, head, body tags, etc). As for why you see no content on the one page, notice that your <script> tag is incomplete? It ends with type= but then cuts out without being closed. That is why your content doesn't display as the browser thinks it's all part of the script tag. The fix for this would normally be to finish your script tag, like you did in your other files. However, in your case you want to just remove all this code as mentioned above. Quote Link to comment https://forums.phpfreaks.com/topic/311522-php-code-works-in-all-files-except-for-one/#findComment-1581583 Share on other sites More sharing options...
namednad Posted September 26, 2020 Author Share Posted September 26, 2020 10 minutes ago, kicken said: Notice how after your devotional div you have another DOCTYPE and begining of an HTML document? That's not correct. The doctype and all that stuff in the <head> should only ever appear once in a page. Your include file apparently has another copy of it that you need to remove. This appears to be a problem not only in the file that doesn't display, but also in your other files that do work. All the .html files you're including as content into the page should contain only the HTML content to be displayed and not all the other page structure (doctype, head, body tags, etc). As for why you see no content on the one page, notice that your <script> tag is incomplete? It ends with type= but then cuts out without being closed. That is why your content doesn't display as the browser thinks it's all part of the script tag. The fix for this would normally be to finish your script tag, like you did in your other files. However, in your case you want to just remove all this code as mentioned above. Thank you Kickens, but again what you looked at is not my php file. What you saw was what I copied from the resultant browser source code which benanamen requested to see 3 hours ago. I tried to attach a text file of the actual php file for that page that is on my server but this forum does not accept it. All of the other index.php files with the exact same php code work flawlessly, just not this file and I don't understand it. Even this file had worked for years until recently. Here is the actual index.php file for that webpage: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link REL="SHORTCUT ICON" HREF="/tlog-icon.ico" type="image/x-icon"><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script type="text/javascript"> BLB.Tagger.Translation = 'KJV'; BLB.Tagger.HyperLinks = 'all'; // 'all', 'none', 'hover' BLB.Tagger.HideTanslationAbbrev = false; BLB.Tagger.TargetNewWindow = true; BLB.Tagger.Style = 'par'; // 'line' or 'par' BLB.Tagger.NoSearchTagNames = ''; // HTML element list BLB.Tagger.NoSearchClassNames = 'noTag doNotTag'; // CSS class list </script> <style type="text/css"> body { font-family: LeagueGothic, Arial, Helvetica, sans-serif; font-color: 888888; } </style> <script src="https://www.blueletterbible.org/assets/scripts/blbToolTip/BLB_ScriptTagger-min.js" type="text/javascript"></script> <title>Today's Daily Light On The Daily Path</title> </head> <body> <center><h3>This Evening's Reading of Daily Light On The Daily Path</h3> <h4>Prepared by Jonathan Bagster and other members of his family</h4> <h4><a href="https://www.theloveofgod.org/devotionals/DailyLight/Morn/index.php">Go to This Morning's Reading</a></h4> <h6><em>Move your mouse over the verse reference to read the entire verse in NKJV version which is written in modern english.</em> </h6></center> <div id="devotional"><?php include ( date("z") . ".html" ); ?></div> <?php error_reporting(E_ALL); ?> </body> </html> Respectfully, namednad Quote Link to comment https://forums.phpfreaks.com/topic/311522-php-code-works-in-all-files-except-for-one/#findComment-1581584 Share on other sites More sharing options...
kicken Posted September 26, 2020 Share Posted September 26, 2020 2 minutes ago, namednad said: All of the other index.php files with the exact same php code work flawlessly, Because the problem isn't in your PHP code, it's in your included .html files. I actually went to the URL from your screenshot and looked at the site before posting, not just at the code here. You can see the problem if you just load your HTML file directly in the browser and exclude the PHP file entirely. The direct cause of the content not displaying is the error in your script tag as I said. However, as I also said, your .html files are incorrect for use as an include file as they contain all the boilerplate html markup which should NOT be there when the content is included into another page. Your 268.html file should contain only this content: <p> Yea, hath God said? Gen. 3:1<br> <br> When the tempter came to Jesus, he said, If thou be the Son of God. Matt. 4:3<br> <br> Jesus said unto him, It is written.... it is written... it is written. Matt. 4:4, 7, 10<br> <br> Then the devil leaveth him. Matt. 4:11<br> <br> I may not return with thee. For it was said to me by the word of the LORD, Thou shalt eat no bread nor drink water there. He said unto him, I am a prophet also as thou art; and an angel spake unto me by the word of the LORD, saying, Bring him back with thee into thine house, that he may eat bread and drink water. But he lied unto him. So he went back with him. The man of God.... was disobedient unto the word of the LORD: therefore the LORD hath delivered him unto the lion, which hath torn him, and slain him, according to the word of the LORD. I Kings 13:16-19 & 26<br> <br> Though we, or an angel from heaven, preach any other gospel unto you than that which we have preached unto you, let him be accursed. Gal. 1:8<br> <br> Thy word have I hid in mine heart, that I might not sin against thee. Psa. 119:11 </p> None of that boilerplate code. So what you should be doing is going through all your .html files and removing all that extra code. Quote Link to comment https://forums.phpfreaks.com/topic/311522-php-code-works-in-all-files-except-for-one/#findComment-1581586 Share on other sites More sharing options...
namednad Posted September 26, 2020 Author Share Posted September 26, 2020 28 minutes ago, kicken said: Because the problem isn't in your PHP code, it's in your included .html files. I actually went to the URL from your screenshot and looked at the site before posting, not just at the code here. You can see the problem if you just load your HTML file directly in the browser and exclude the PHP file entirely. The direct cause of the content not displaying is the error in your script tag as I said. However, as I also said, your .html files are incorrect for use as an include file as they contain all the boilerplate html markup which should NOT be there when the content is included into another page. Your 268.html file should contain only this content: <p> Yea, hath God said? Gen. 3:1<br> <br> When the tempter came to Jesus, he said, If thou be the Son of God. Matt. 4:3<br> <br> Jesus said unto him, It is written.... it is written... it is written. Matt. 4:4, 7, 10<br> <br> Then the devil leaveth him. Matt. 4:11<br> <br> I may not return with thee. For it was said to me by the word of the LORD, Thou shalt eat no bread nor drink water there. He said unto him, I am a prophet also as thou art; and an angel spake unto me by the word of the LORD, saying, Bring him back with thee into thine house, that he may eat bread and drink water. But he lied unto him. So he went back with him. The man of God.... was disobedient unto the word of the LORD: therefore the LORD hath delivered him unto the lion, which hath torn him, and slain him, according to the word of the LORD. I Kings 13:16-19 & 26<br> <br> Though we, or an angel from heaven, preach any other gospel unto you than that which we have preached unto you, let him be accursed. Gal. 1:8<br> <br> Thy word have I hid in mine heart, that I might not sin against thee. Psa. 119:11 </p> None of that boilerplate code. So what you should be doing is going through all your .html files and removing all that extra code. Here is my actual 268.html file code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <script src="https://www.blueletterbible.org/assets/scripts/blbToolTip/BLB_ScriptTagger-min.js" type= <title>Untitled Document</title> </head> <body> <p> Yea, hath God said? Gen. 3:1<br> <br> When the tempter came to Jesus, he said, If thou be the Son of God. Matt. 4:3<br> <br> Jesus said unto him, It is written.... it is written... it is written. Matt. 4:4, 7, 10<br> <br> Then the devil leaveth him. Matt. 4:11<br> <br> I may not return with thee. For it was said to me by the word of the LORD, Thou shalt eat no bread nor drink water there. He said unto him, I am a prophet also as thou art; and an angel spake unto me by the word of the LORD, saying, Bring him back with thee into thine house, that he may eat bread and drink water. But he lied unto him. So he went back with him. The man of God.... was disobedient unto the word of the LORD: therefore the LORD hath delivered him unto the lion, which hath torn him, and slain him, according to the word of the LORD. I Kings 13:16-19 & 26<br> <br> Though we, or an angel from heaven, preach any other gospel unto you than that which we have preached unto you, let him be accursed. Gal. 1:8<br> <br> Thy word have I hid in mine heart, that I might not sin against thee. Psa. 119:11 </p></body> </html> I mentioned in my original post I have absolutely no code training at all and over 30 years I have used some cut and paste code. All of my html files were created using Dreamweaver. I apologize for my ignorance. So I need to remove the bold code above from all of my html files? Respectfully, dan Quote Link to comment https://forums.phpfreaks.com/topic/311522-php-code-works-in-all-files-except-for-one/#findComment-1581587 Share on other sites More sharing options...
kicken Posted September 26, 2020 Share Posted September 26, 2020 3 minutes ago, namednad said: So I need to remove the bold code above from all of my html files? Yes, from all the ones you are using as an include file. Those parts of the code should only exist once in your page. You already have them in your PHP file so you don't want them in your html files as well. Quote Link to comment https://forums.phpfreaks.com/topic/311522-php-code-works-in-all-files-except-for-one/#findComment-1581588 Share on other sites More sharing options...
namednad Posted September 26, 2020 Author Share Posted September 26, 2020 I removed the excess code from the 268.html file and it works great. Thank you so much kicken! I've got my work cut out now. I have 11 devotionals, some have 2 and 3 folders each enough files for daily Julian Dates for a year. I'll start tomorrow after I correct the Eve directory files tonight just to get those files working. Thanks again for teaching an ignorant old dog a new trick! Respectfully, namednad Quote Link to comment https://forums.phpfreaks.com/topic/311522-php-code-works-in-all-files-except-for-one/#findComment-1581589 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.