Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.