skylab Posted August 26, 2013 Share Posted August 26, 2013 I'm trying to add an include inside regular text. I don't know why it doesn't work. It's ignoring the in_header.php even though I escaped the ' with a \ Any help would be greatly appreciated. <?php //MySQL Database Connect include 'bind.php'; $sql = mysql_query("SELECT * FROM sql_test WHERE Name= 'TEST'"); while($result = mysql_fetch_array($sql)) { echo $result["Name"]. $result["Gender"]. 'TEXT TEXT TEXT <?php include \'inc_header.php\'?> Text Text Text'; } ?> Link to comment https://forums.phpfreaks.com/topic/281556-include/ Share on other sites More sharing options...
ryanmetzler3 Posted August 26, 2013 Share Posted August 26, 2013 try this instead require ('bind.php'); Link to comment https://forums.phpfreaks.com/topic/281556-include/#findComment-1446760 Share on other sites More sharing options...
skylab Posted August 26, 2013 Author Share Posted August 26, 2013 The problem is not with 'bind.php' that one works and I'm able to connect to sql and retrieve Name and Gender. But the <?php include 'inc_header.php'?> is the file which is ignored. I tried your advice but it didn't work. Link to comment https://forums.phpfreaks.com/topic/281556-include/#findComment-1446762 Share on other sites More sharing options...
trq Posted August 26, 2013 Share Posted August 26, 2013 Your already within php tags, you don't need more. Also, includes don't need to be echoed. echo $result["Name"] . $result["Gender"] . 'TEXT TEXT TEXT'; include 'inc_header.php'; echo 'Text Text Text'; Link to comment https://forums.phpfreaks.com/topic/281556-include/#findComment-1446766 Share on other sites More sharing options...
skylab Posted August 26, 2013 Author Share Posted August 26, 2013 That did it thanks a lot. That will save me a lot time and effort. Have a great week. Link to comment https://forums.phpfreaks.com/topic/281556-include/#findComment-1446772 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.