Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-16-2004, 02:19 PM   PM User | #1
boeing747fp
Regular Coder

 
Join Date: Oct 2003
Posts: 599
Thanks: 1
Thanked 1 Time in 1 Post
boeing747fp is an unknown quantity at this point
IPB not accepting custom codes

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
boeing747fp is offline   Reply With Quote
Old 10-16-2004, 03:40 PM   PM User | #2
fci
Senior Coder

 
Join Date: Aug 2004
Location: Twin Cities
Posts: 1,345
Thanks: 0
Thanked 0 Times in 0 Posts
fci is an unknown quantity at this point
I see no syntax errors, maybe there is something above or below where you placed the code which you accidentially modified.. ?

and your link..
Quote:
The following errors were found:
The board administrator does not allow Guests to post or reply. Please Login or Register to continue.
fci is offline   Reply With Quote
Old 10-16-2004, 05:11 PM   PM User | #3
raf
Master Coder


 
Join Date: Jul 2002
Posts: 6,589
Thanks: 0
Thanked 0 Times in 0 Posts
raf will become famous soon enoughraf will become famous soon enough
Quote:
Originally Posted by boeing747fp
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 ...
__________________
Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html
raf is offline   Reply With Quote
Old 10-16-2004, 06:41 PM   PM User | #4
fci
Senior Coder

 
Join Date: Aug 2004
Location: Twin Cities
Posts: 1,345
Thanks: 0
Thanked 0 Times in 0 Posts
fci is an unknown quantity at this point
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
fci is offline   Reply With Quote
Old 10-16-2004, 11:36 PM   PM User | #5
boeing747fp
Regular Coder

 
Join Date: Oct 2003
Posts: 599
Thanks: 1
Thanked 1 Time in 1 Post
boeing747fp is an unknown quantity at this point
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?
boeing747fp is offline   Reply With Quote
Old 10-17-2004, 12:07 AM   PM User | #6
kliqster
New Coder

 
Join Date: Feb 2004
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
kliqster is an unknown quantity at this point
Quote:
Originally Posted by boeing747fp
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" );

if(
$DB->num_rows$sql ) >)
{
   
$current_user_status "Online";
}

else
{
   
$current_user_status "Offline";
}  

$info['current_user_status'] = $current_user_status
You can then go into the HTML templates for the profile view and use {$info['current_user_status']} wherever you want to echo the user's status.

Last edited by kliqster; 10-17-2004 at 12:15 AM..
kliqster is offline   Reply With Quote
Old 10-17-2004, 01:02 AM   PM User | #7
boeing747fp
Regular Coder

 
Join Date: Oct 2003
Posts: 599
Thanks: 1
Thanked 1 Time in 1 Post
boeing747fp is an unknown quantity at this point
didnt work... this is the error now on all profile pages

Fatal error: Call to undefined function: num_rows() in /home/condraft/public_html/boards/sources/Profile.php on line 394

Last edited by boeing747fp; 10-17-2004 at 01:05 AM..
boeing747fp is offline   Reply With Quote
Old 10-17-2004, 01:15 AM   PM User | #8
boeing747fp
Regular Coder

 
Join Date: Oct 2003
Posts: 599
Thanks: 1
Thanked 1 Time in 1 Post
boeing747fp is an unknown quantity at this point
nvm... i got it to work now... thanks
boeing747fp is offline   Reply With Quote
Old 10-17-2004, 01:36 AM   PM User | #9
kliqster
New Coder

 
Join Date: Feb 2004
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
kliqster is an unknown quantity at this point
Quote:
Originally Posted by boeing747fp
nvm... i got it to work now... thanks
Forgot the 'get_'

Glad you got it sorted anyway.
kliqster is offline   Reply With Quote
Old 11-12-2004, 02:40 PM   PM User | #10
boeing747fp
Regular Coder

 
Join Date: Oct 2003
Posts: 599
Thanks: 1
Thanked 1 Time in 1 Post
boeing747fp is an unknown quantity at this point
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
boeing747fp is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:04 AM.


Advertisement
Log in to turn off these ads.