Jump to content

HELP!! I am new to PHP and I am having problems with (inc config.php)


electripunk

Recommended Posts

Ok, first of all, I am new to php and css. I am rewriting a script that I liked the idea, but the layout was no good, and half the links were no good.

 

So now I am still in the beginning with the home page, an about.php , and the normal footer, header, under an inc sub directory, and a lib sub directory with a function.php

 

I am trying to get the contact us page up. The way it is written uses a contact.php and its own index.php. 

 

I have the same tag to include the header, but it does not seem to work.

 

In my root directory, my include code is

 

include('config.php');

include ($sm['path_inc'] . 'header.php');

$sm['page_name'] = 'Welcome to ' . $sm['page_name'];

 

but in the sub directory it is

 

include('../config.php');

include ($sm['path_inc'] . 'header.php');

$sm['page_name'] = 'Welcome to ' . $sm['page_name'];

 

 

However, on the contact us page, my header image does not show up. All the css works, and the menus work and are accessable. This has had me stumped for a day and a half. Why cant I get my site logo to show up in a index.php located in a sub directory?

 

 

Someone please help...

Link to comment
Share on other sites

...well i found out in alot of my code, when im trying to put a navigation url, it normally works if i take the . out so try

 

include('/config.php');

include ($sm['path_inc'] . 'header.php');

$sm['page_name'] = 'Welcome to ' . $sm['page_name'];

 

problem is, that would only like to the file in the same directory, if you wanted one in another directory

you would have to do something like this, e.g. my folder is called Newfolder and my file im trying to link to is called Newfile.php:

 

include('Newfolder/Newfile.php')...

 

is this what you were trying to get at?

Link to comment
Share on other sites

Thank you very much for your suggestions. I have tried to post it without the

".." before "/config.php" but it gave me errors every time I tried to leave the page with a link.

 

My config file hase a path_inc definition. That is where the include ($sm['path_inc'] . 'header.php');

comes in.

 

The ../config.php works

 

I know it works because all my links are working and my header, and footer show up. The problem is that my image will not show up when the header is linked with php from a sub directory.

 

in short,

 

include ($sm['path_inc'] . 'header.php');

 

is actually

 

"html/test/inc/header.php"

 

the root is /test/

 

the issue is when  I test the site, everything works up until

 

html/test/contact/index.php    <~~~this page will not show the site logo in the header, but still displays everything else in the header. I am usinga .png for the site logo.

Link to comment
Share on other sites

PROBLEM SOLVED!!!

 

Apparently I had some issues in my config.php file.

 

Not sure why this worked, but I changed

 

$sm['dir_images'] = 'specific directory tree beginning before the html/ directory /test/images/';

 

to simply

 

$sm['dir_images'] = '/test/images/';

 

then I actually used the link to the config.php file in my contact form, and updated my header.php

 

to <img src="{dir_base}logo.png">

 

Works great!! Thank you for your suggestions.

 

 

Link to comment
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.