Canadian Posted July 3, 2011 Share Posted July 3, 2011 I've been using includes for quite some time. However, whatever I'm doing today is not working. What am I doing wrong? Here is my included file... <?php $host ='XXXXXXXX'; $username = 'YYYYYYYYY'; $password 'TTTTTTTTTT'; $database = 'GGGGGGGGGG'; ?> And here is the file where I include it an try to echo one of the variables. I'm getting nothing. What am I doing wrong? <!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" /> <title>Untitled Document</title> </head> <body> <?php include("protected_info.php"); echo $password; ?> </body> </html> Thanks, Chris Quote Link to comment https://forums.phpfreaks.com/topic/241022-include-help/ Share on other sites More sharing options...
regoch Posted July 3, 2011 Share Posted July 3, 2011 $password 'TTTTTTTTTT'; should be $password = 'TTTTTTTTTT'; Quote Link to comment https://forums.phpfreaks.com/topic/241022-include-help/#findComment-1237997 Share on other sites More sharing options...
Bradley99 Posted July 3, 2011 Share Posted July 3, 2011 Include file... Password should be $password = 'TTTTTTTTTTTT' ; Quote Link to comment https://forums.phpfreaks.com/topic/241022-include-help/#findComment-1237998 Share on other sites More sharing options...
Canadian Posted July 3, 2011 Author Share Posted July 3, 2011 $password 'TTTTTTTTTT'; should be $password = 'TTTTTTTTTT'; Duh! Ok thanks. Now it's not working here. Does it have something to do with my absolute link? TEST prints but $password will not. <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> </head> <body> <?php include("http://www.xxx.com/protected/protected_info.php"); echo "TEST"; echo $password; ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/241022-include-help/#findComment-1238003 Share on other sites More sharing options...
mikesta707 Posted July 3, 2011 Share Posted July 3, 2011 include/require statements and their derivatives uses file paths, not URLs, to find the page you are including. You need to supply either an absolute or relative file path to the file you want. Assuming the page with the code you posted is in the main directory, (IE if its called page.php, you can get to it by going to xxx.com/page.php), the correct relative path would b "protected/protected_info.php" Quote Link to comment https://forums.phpfreaks.com/topic/241022-include-help/#findComment-1238005 Share on other sites More sharing options...
Canadian Posted July 3, 2011 Author Share Posted July 3, 2011 include/require statements and their derivatives uses file paths, not URLs, to find the page you are including. You need to supply either an absolute or relative file path to the file you want. Assuming the page with the code you posted is in the main directory, (IE if its called page.php, you can get to it by going to xxx.com/page.php), the correct relative path would b "protected/protected_info.php" Thank you. Let me try that when I get back to my computer. Quote Link to comment https://forums.phpfreaks.com/topic/241022-include-help/#findComment-1238025 Share on other sites More sharing options...
Canadian Posted July 4, 2011 Author Share Posted July 4, 2011 include/require statements and their derivatives uses file paths, not URLs, to find the page you are including. You need to supply either an absolute or relative file path to the file you want. Assuming the page with the code you posted is in the main directory, (IE if its called page.php, you can get to it by going to xxx.com/page.php), the correct relative path would b "protected/protected_info.php" Ok. I'm trying to use the included variables on a contact form response page. If I open the page below as it's own webpage I see TTTTTTTT on the screen. If however, I put the same code on my response page I get nothing. Am I having a problem with the variables because I am coming to this page via a form submit button? Thanks again, <!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" /> <title>Untitled Document</title> </head> <body> <?php include("protected_info.php"); echo $password; ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/241022-include-help/#findComment-1238044 Share on other sites More sharing options...
mikesta707 Posted July 4, 2011 Share Posted July 4, 2011 is there an error? Do you get a blank page? Try turning error reporting on by putting this at the top of your page ini_set('display_errors',1); error_reporting(E_ALL); Quote Link to comment https://forums.phpfreaks.com/topic/241022-include-help/#findComment-1238045 Share on other sites More sharing options...
Canadian Posted July 4, 2011 Author Share Posted July 4, 2011 is there an error? Do you get a blank page? Try turning error reporting on by putting this at the top of your page ini_set('display_errors',1); error_reporting(E_ALL); I got it fixed. Thanks for your help. I had a sytax error. Take care, Quote Link to comment https://forums.phpfreaks.com/topic/241022-include-help/#findComment-1238055 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.