Jump to content

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/152825-is-this-a-problem-with-the-server/
Share on other sites

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;

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.