I am working on placing a forum login box on the index of my site. Here is the code I am working with . <?php if($mybb->user['uid']) { ��// The user is logged in, say Hi [COLOR="Red"]echo "Hey, $mybbuser[username].<br>[/COLOR] Thanks for logging in."; } else { ��// The user is not logged in, Display the form echo "<form action='petchat/member.php' method='post'> Username: <input type='text' name='username' size='25' maxlength='30' /><br /> Password: <input type='password' name='password' size='25' /> <input type='hidden' name='action' value='do_login'> <input type='hidden' name='url' value='index.php' /> <input type='submit' class='submit' name='submit' value='Login' /></form><br>"; } ?> Code (markup): The error I get is Parse error: syntax error, unexpected T_ECHO in /home/journey/public_html/overhau2.php on line 105 Code (markup): Line 105 has been highlighted in red. Thank you for any help you can give Adam Burgi
Try replacing it with this: echo "Hey, ".$mybbuser['username']."<br>Thanks for logging in."; Code (markup): p.s. you have some kind of "??" characters in the code, they should be removed
That won't work, first you forgot '.' to concatenate the strings and second the "\n" is no replacement for "<br />", it will make line break in the source code, yeah, but it won't be displayed as linebreak on the website.
Could it not also be the fact that you have a double question mark apparently doing nothing above it? It could be trying to parse them as a double ternary operator.
Thank you everyone. echo "Hey, $mybbuser[username].<br> It did seem to be the "." took that out and it works.....well sort of. It is supposed to show who you are signed in as once you are signed in. Ehhhh at least I have gotten somewhere.
Then you probably need to use: $mybb->user['username'] and not $mybbuser[username] But take my version from above, with ".", that should work 100% just replace it with $mybb->user['username'] Btw. rep+ button is in the top right corner
There could be a few solutions why this is not working. As I don't know how your script is setup, here are a few solutions: First remember to put array outputs inside { and } (left brace/left curly bracket and right brace/right curly bracket) when placed inside quotations or apostrophes. In this case you are using quotations in your echo function. Array examples: $mybb->user['uid'] or $mybbuser['username'] echo "Hey, {$mybb->username]}.<br> Thanks for logging in."; //If you unintentionally changed $mybb to $mybbuser echo "Hey, {$mybbuser['username']}.<br> Thanks for logging in."; //if you forgot to add the apostrophes I highly recommend you try out Nusphere PhpED.
Thank you. I will check out that link. I think I read somewhere that the code $mybbuser Code (markup): changed so I am trying to look into that.
OK. I do not expect anyone on here to really care how I got this to work. But incase there is a "mybb" user here that wants to know I figured I would post it. // The user is logged in, say Hi echo "Hey, $mybbuser[username].<br> Thanks for logging in."; Code (markup): // The user is logged in, say Hi echo "Hey, {$mybb->user['username']}.<br> Thanks for logging in."; Code (markup): It was part of a code change with the latest version of mybb. Thank you for everyone who replied to this post.