i cant get my code below to work in IPB... it just says UNEXPECTED T_ENCAPSED_WHITESPACE
PHP Code:
$con = mysql_connect("localhost","user","pass");
$user = $_GET['showuser'];
$time = time()-900;
$sql = mysql_query("SELECT * FROM `ibf_sessions` WHERE `member_id` = '$user' AND `running_time` > '$time' LIMIT 1") or die(mysql_error());
if(mysql_num_rows($sql) >0){
$current_user_status = "Online";
}else{
$current_user_status = "Offline";
}
^ i put this in skin_profile.php and then in the Profile HTML modifier in IPB, i cant get the php code to work... it's supposed to show the user as being online or offline here http://condraft.com/boards/index.php?showuser=18
i cant get my code below to work in IPB... it just says UNEXPECTED T_ENCAPSED_WHITESPACE
PHP Code:
$con = mysql_connect("localhost","user","pass");
$user = $_GET['showuser'];
$time = time()-900;
$sql = mysql_query("SELECT * FROM `ibf_sessions` WHERE `member_id` = '$user' AND `running_time` > '$time' LIMIT 1") or die(mysql_error());
if(mysql_num_rows($sql) >0){
$current_user_status = "Online";
}else{
$current_user_status = "Offline";
}
^ i put this in skin_profile.php and then in the Profile HTML modifier in IPB, i cant get the php code to work... it's supposed to show the user as being online or offline here http://condraft.com/boards/index.php?showuser=18
Do you have a linenumber with that error?
Also, i don't see you select a db anywhere ...
found this in the php extended manual chm when I was looking for something else ..
Quote:
I got a "T_ENCAPSED_AND_WHITESPACE" parse error on one of my php files, and did not understand why.
When I read your post about this, I first of all tried the {} brackets idea, but found that it did not work. I then removed all instances of [' '] and replaced them with [ ]. Then it worked.
Satan
Quote:
if you get a parse error saying that there was an unexpected T_ENCAPSED_AND_WHITESPACE, you've probably got an array within double quoted strings being parsed incorrectly.
For example:
$foo = $_GET['foo'];
echo "foo is $foo"; // works fine
However,
echo "foo is $_GET['foo']"; // parse error
Inside double-quoted strings, an identifier found within square brackets (after a variable, of course) is parsed as a string index. This identifier must be either a string, another variable, or a number. Since the single-quote around foo doens't fit (to the parser, anyway) any of these tokens, you get the parse error.
To remove the error, remove the single quotes, OR use the curly-brace syntax (recommended, as it's required for more complex substitution anyway).
echo "foo is {$_GET['foo']}"; // works
echo "foo is $_GET[foo]"; // also works
well, there's not an error when i just do that... but if i put that code above i mentioned into the IPB Profile skin, it just errors out... and i cant seem to get it to echo a session or regular variable either...
what i really need to know is this....
IPB has the template like this --> where they echo the user's name in the profile template, they only put {$info[member_name]}
i need to know how to make something like that so that in the html file, stuff inside the {} tags is parsed in PHP... i tried define() but that requires me to put <? and ?> around the echo {$}; tag... can anyone help me out figurin out how people do this {} in the html templates?
well, there's not an error when i just do that... but if i put that code above i mentioned into the IPB Profile skin, it just errors out... and i cant seem to get it to echo a session or regular variable either...
what i really need to know is this....
IPB has the template like this --> where they echo the user's name in the profile template, they only put {$info[member_name]}
i need to know how to make something like that so that in the html file, stuff inside the {} tags is parsed in PHP... i tried define() but that requires me to put <? and ?> around the echo {$}; tag... can anyone help me out figurin out how people do this {} in the html templates?
IPB doesn't parse PHP in it's templates - that includes the skin_*.php files.
What you need to do is this:
I assume you want to modify the profile view in some way, yeah? And that you're using v1.3(.1)?
Open up sources/Profile.php and find the following lines inside the view_profile function:
PHP Code:
if ($info['posts_day'] > $member['posts'])
{
$info['posts_day'] = $member['posts'];
}
add the following code below:
PHP Code:
$time = time() -900;
$sql = $DB->query( "SELECT * FROM `ibf_sessions` WHERE `member_id` = '{$ibforums->input['MID']}' AND `running_time` > '$time' LIMIT 1" );
but how do i get it do take codes where i want them? i have an extension to the Online.php and it keeps putting the stuff at the top instead of where i call it in the skin fike