|
Issue with PHP and a variable
|
|
11-09-2008, 01:38 AM
Post: #1
|
|||
|
|||
|
Issue with PHP and a variable
Alright, I made it so that I can use PHP in templates, but I am having this issue. I want to display a user's Group ID, but here's what happens:
If I put PHP Code: <?phpPHP Code: Warning: Unexpected character in input: '\' (ASCII=92) state=1 in directory/global.php(433) : eval()'d code(27) : eval()'d code on line 2If I make it PHP Code: <?phpPHP Code: \{Array[\usergroup\]\} What can I do? Or is there an alternate way? BTW, I am adding the PHP into the main header template. Need web hosting? Try MyBBWebHost! #1 for Running MyBB Communities ------- Biodegradable Sunscreen - Unblock Facebook |
|||
|
11-09-2008, 03:23 PM
(This post was last modified: 11-09-2008 03:24 PM by Tomm M.)
Post: #2
|
|||
|
|||
|
RE: Issue with PHP and a variable
How have you got to use PHP in templates - did you use a modification?
If so, you're probably best off looking into the author's support forums. An alternative way would be do: PHP Code: <?php echo "{".$mybb->user['usergroup']."}"; ?>... but I don't think it would make much difference (that's just the way I'd code it)... Edit: Could it be to do with the { } tags?... try removing them or changing them to specialchars... |
|||
|
11-09-2008, 04:55 PM
(This post was last modified: 11-10-2008 01:55 AM by Zash.)
Post: #3
|
|||
|
|||
RE: Issue with PHP and a variable
(11-09-2008 03:23 PM)Tom.M Wrote: How have you got to use PHP in templates - did you use a modification?I did that and it just deleted everything after it in the templates ![]() C'mon, nobody can help me? Just bumping it so it goes back to the top. Need web hosting? Try MyBBWebHost! #1 for Running MyBB Communities ------- Biodegradable Sunscreen - Unblock Facebook |
|||
|
11-10-2008, 07:57 PM
Post: #4
|
|||
|
|||
|
RE: Issue with PHP and a variable
Ok Bump? (Hoping this works)
Need web hosting? Try MyBBWebHost! #1 for Running MyBB Communities ------- Biodegradable Sunscreen - Unblock Facebook |
|||
|
11-10-2008, 07:59 PM
Post: #5
|
|||
|
|||
|
RE: Issue with PHP and a variable
Well this is obviously a problem with your modification. Can you post it here? I suspect you are having problems because $templates->get() automatically backslashes double quotation marks (") so I think you should stripslashes before you eval the PHP.
Dennis Tsang :: MyBB Developer Follow me on Twitter: @dennistt |
|||
|
11-10-2008, 09:37 PM
Post: #6
|
|||
|
|||
|
RE: Issue with PHP and a variable
You can already just use a variable in the code though, if you're not meaning to extend it futher to functions and stuff.
|
|||
|
11-11-2008, 09:28 PM
Post: #7
|
|||
|
|||
RE: Issue with PHP and a variable
(11-10-2008 07:59 PM)DennisTT Wrote: Well this is obviously a problem with your modification. Can you post it here? I suspect you are having problems because $templates->get() automatically backslashes double quotation marks (") so I think you should stripslashes before you eval the PHP.This is the modification: http://community.mybboard.net/thread-318...+templates (11-10-2008 09:37 PM)CraKteR Wrote: You can already just use a variable in the code though, if you're not meaning to extend it futher to functions and stuff. I am trying to make a PHP if else statement so that text would show if a member is in a certain group, but not in another. Need web hosting? Try MyBBWebHost! #1 for Running MyBB Communities ------- Biodegradable Sunscreen - Unblock Facebook |
|||
|
11-12-2008, 10:00 PM
Post: #8
|
|||
|
|||
|
RE: Issue with PHP and a variable
Bump
Need web hosting? Try MyBBWebHost! #1 for Running MyBB Communities ------- Biodegradable Sunscreen - Unblock Facebook |
|||
|
11-14-2008, 01:17 AM
Post: #9
|
|||
|
|||
|
RE: Issue with PHP and a variable
No Help?
Need web hosting? Try MyBBWebHost! #1 for Running MyBB Communities ------- Biodegradable Sunscreen - Unblock Facebook |
|||
|
11-14-2008, 02:49 AM
Post: #10
|
|||
|
|||
RE: Issue with PHP and a variable This user has been denied support.
$mybb->user['usergroup']
Try it without the single quotes $mybb->user[usergroup] Also look into the displaygroup for the user...should be $mybb->user['displayusergroup'] or something like that. Do a print_r($mybb->user) to get all the variables available. New MyBB plugin is "My Awards 2.0".
|
|||
|
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)
Search
Member List
Calendar
Help






This user has been denied support.
![[Image: 468x60_SF.gif]](http://supportforums.net/images/banners/468x60_SF.gif)