MyBB Community Forums

Full Version: Adding "Hello, Guest" and "Welcome back, {username}" to main site.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
You'd need a lot of changes to Tikitikis code to make it actually work.

You need
define('IN_MYBB', 1);
above the require line.
Ok, that works, thank you.
BUT, two more things I'm afraid:

1) As soon as I try making Login/Register/Logout/etc into links, I get this error:
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING
Am I doing them wrong somehow? I apologize for all the questions, but I am not good with this kind of stuff and even minor problems trouble me.

2) Are the changes I'd need to make to Tikitiki's code significant enough to worry about? Would things work better if they were made?
Still hoping to get this figured out if one of you two can spare the time.
Any idea why I'm getting this latest error?

Cheers.
*drinks on me*
Just another bump to the first page.
Really hoping to get this resolved soon.

Thanks much.
jedk Wrote:Ok, that works, thank you.
BUT, two more things I'm afraid:

1) As soon as I try making Login/Register/Logout/etc into links, I get this error:
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING
Am I doing them wrong somehow? I apologize for all the questions, but I am not good with this kind of stuff and even minor problems trouble me.
Which files does it say the error is in?
jedk Wrote:2) Are the changes I'd need to make to Tikitiki's code significant enough to worry about? Would things work better if they were made?
I don't understand? As you said it didn't work with Tikitikis code?
Ok, I figured it out. I made an error in how I was forming my links in the php code.
A silly mistake, yes... but then again, my PHP skills are pretty much zilch, so there ya go.

All figured out now (I think).
I appreciate the help very much.
Sorry if this is a dumb question, but...
...how do I change the following code so that it will work if I am calling it from a file that's placed somewhere other than my root directory?

include "./forum/inc/config.php";
require "./forum/inc/db_mysql.php";
define('IN_MYBB', 1);
require "./forum/inc/init.php";

If I change them from "./forum/inc/config.php"; (etc.) to "http://www.myurl.com/forum/inc/config.php"; I get an error, so... what is the correct way to do it?
I know this is a really n00b question, but that's exactly what I am when it comes to PHP.

Thank you.
Where on your site would you like to put it? and I'll tell you what to change Smile
jedk Wrote:Sorry if this is a dumb question, but...
...how do I change the following code so that it will work if I am calling it from a file that's placed somewhere other than my root directory?

include "./forum/inc/config.php";
require "./forum/inc/db_mysql.php";
define('IN_MYBB', 1);
require "./forum/inc/init.php";

If I change them from "./forum/inc/config.php"; (etc.) to "http://www.myurl.com/forum/inc/config.php"; I get an error, so... what is the correct way to do it?
I know this is a really n00b question, but that's exactly what I am when it comes to PHP.

Thank you.

You don't use your domain name there, the path is actually your system path, for example in Windows, C:\Documents and Settings\blahblahblah

You'll have to get your path from your phpinfo(); output.

Once you've gotten that, scroll down towards the bottom and look for _SERVER["DOCUMENT_ROOT"]. The value of that is your document root, where http://yourdomain.com/index.php resides. Hope that helps.

Which, for example, results in this:

include "(_SERVER["DOCUMENT_ROOT"])/forum/inc/config.php";
require "(_SERVER["DOCUMENT_ROOT"])/forum/inc/db_mysql.php";
define('IN_MYBB', 1);
require "(_SERVER["DOCUMENT_ROOT"])/forum/inc/init.php";
where (_SERVER["DOCUMENT_ROOT"]) is the value of _SERVER["DOCUMENT_ROOT"]
Wow, that's neat, Sephiroth!

And sorry I didn't understand what you were intending, jedk! This is actually a good idea. I've been playing around with it on my site. Got it working, but it doesn't recognize that I'm logged in on the forum. It says I'm a guest on my main site! Did you get it to recognize you on your site?
Although you might just use dirname(__FILE__) to get the dirname of the current directory as we do in MyBB.

Although I do think you mean:
include $_SERVER["DOCUMENT_ROOT"]."/forum/inc/config.php";
CraKteR is correct, Sephiroth's way would cause a php error
Pages: 1 2 3