I am getting my hands on webdev at the moment and am facing a strange issue: I have two php includes in one html file. Unfortunately only the first include is working, the second one seems to stop transfering the html code to browser. There is no mistake in the corresponding php files since the html file is loading proplery, once I disable one of the includes. Can somebody explain this issue?
... <div class="wrapper"> <div class="left"> ... </div> <div id="div_table" class="center"> <table id="mytable" cellspacing="0" width="100%"> <?php include("../php/table_data.php"); ?> </table> </div> </div> <div id="div_add_element" title="Add element"> <form id="form_add_element"> <table> <tr> <td><label for="id_name">Name</label></td> <td><input id="id_name" name="name" type="text" width="30"> </input></td> </tr> <tr> <td><label for="id_edition">Edition</label></td> <td> <select id="id_edition" name="edition"> <?php include("../php/option_editions.php"); ?> </select> </td> </tr> </table> </form> </div>
You cant put PHP code in HTML.
So if you have index.html you can't add php code. Change the name to index.php.
And then use:
include('FILEPATH');
There is no mistake in the corresponding php files since the html file is loading proplery, once I disable one of the includes.
Your reasoning defeats your conclusion. If removing one of the includes makes your HTML work, then your problem is with the include
. If you are accurate in saying that the pasted code is inside an HTML file, then you need to change it to PHP, as you cannot use PHP code inside an HTML file.
When you made sure that your include calls are called inside a PHP file, you need to make check every element in the following list:
chdir
which changes the current folder. getcwd
might help you in determining the directory you use include
or require
only existing files you have access permission to include
or require
the same function or class twice include
include
your files
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.