wemustdesign Posted April 6, 2009 Share Posted April 6, 2009 The last week I have been having many problems when coding with php. I am not sure if it is a problem with my host. Here is the sort of problems I have been having: //=================index.php $test = 1; echo "Main page test =".$test; // ouputs Main page test = 1 fine include 'header.php'; // ouputs Header test = where is the variable going? //==================header.php echo "Header test =".$test; Not sure why header.php isn't picking up the variable? Another problem I am having is including connect.php in my page, just does't work. If I take the content of connect.php and place it above my query it works fine. Don't know what is going on. //===================connect.php $username="user"; $password="pass"; $database="my_database"; mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); Does anybody have any ideas of what the problem might be? Quote Link to comment https://forums.phpfreaks.com/topic/152825-is-this-a-problem-with-the-server/ Share on other sites More sharing options...
iarp Posted April 6, 2009 Share Posted April 6, 2009 Whats the contents of header.php? And how are you including connect.php? Quote Link to comment https://forums.phpfreaks.com/topic/152825-is-this-a-problem-with-the-server/#findComment-802578 Share on other sites More sharing options...
wemustdesign Posted April 6, 2009 Author Share Posted April 6, 2009 I have already included the contents of header.php. I am including connect.php as follows include "connect.php"; Quote Link to comment https://forums.phpfreaks.com/topic/152825-is-this-a-problem-with-the-server/#findComment-802594 Share on other sites More sharing options...
mrMarcus Posted April 6, 2009 Share Posted April 6, 2009 are you sure the location of connect.php and header.php are where your include() is trying to fetch them from? try an absolute path, starting from the very root of your server .. an example might be: include ("/home/wemustdesign/public_html/connect.php"); you can find this via a phpinfo.php file .. under Environment > DOCUMENT_ROOT; Quote Link to comment https://forums.phpfreaks.com/topic/152825-is-this-a-problem-with-the-server/#findComment-802609 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.