Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    Regular Coder
    Join Date
    Oct 2003
    Posts
    603
    Thanks
    2
    Thanked 1 Time in 1 Post

    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

  • #2
    fci
    fci is offline
    Senior Coder
    Join Date
    Aug 2004
    Location
    Twin Cities
    Posts
    1,345
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I see no syntax errors, maybe there is something above or below where you placed the code which you accidentially modified.. ?

    and your link..
    The following errors were found:
    The board administrator does not allow Guests to post or reply. Please Login or Register to continue.

  • #3
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #4
    fci
    fci is offline
    Senior Coder
    Join Date
    Aug 2004
    Location
    Twin Cities
    Posts
    1,345
    Thanks
    0
    Thanked 0 Times in 0 Posts
    found this in the php extended manual chm when I was looking for something else ..
    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
    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

  • #5
    Regular Coder
    Join Date
    Oct 2003
    Posts
    603
    Thanks
    2
    Thanked 1 Time in 1 Post
    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?

  • #6
    New Coder
    Join Date
    Feb 2004
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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 01:15 AM.

  • #7
    Regular Coder
    Join Date
    Oct 2003
    Posts
    603
    Thanks
    2
    Thanked 1 Time in 1 Post
    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 02:05 AM.

  • #8
    Regular Coder
    Join Date
    Oct 2003
    Posts
    603
    Thanks
    2
    Thanked 1 Time in 1 Post
    nvm... i got it to work now... thanks

  • #9
    New Coder
    Join Date
    Feb 2004
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by boeing747fp
    nvm... i got it to work now... thanks
    Forgot the 'get_'

    Glad you got it sorted anyway.

  • #10
    Regular Coder
    Join Date
    Oct 2003
    Posts
    603
    Thanks
    2
    Thanked 1 Time in 1 Post
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •