Jump to content

Include help


Canadian

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/241022-include-help/
Share on other sites

$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>

Link to comment
https://forums.phpfreaks.com/topic/241022-include-help/#findComment-1238003
Share on other sites

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"

Link to comment
https://forums.phpfreaks.com/topic/241022-include-help/#findComment-1238005
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/241022-include-help/#findComment-1238025
Share on other sites

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>

Link to comment
https://forums.phpfreaks.com/topic/241022-include-help/#findComment-1238044
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.