Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 27

Thread: Call to an undefined function???

  1. #11
    Ryan's Avatar
    Ryan is offline WordPress Legend
    Join Date
    Jan 2009
    Location
    New Zealand
    Posts
    2,801

    Default

    Quote Originally Posted by Jwrbloom View Post
    The reason for not putting it in the page template itself is I don't want it on certain pages. I guess I could create a separate template, but that's kind of what I'm doing here, hijacking it a little.
    Then use is_page() ... http://codex.wordpress.org/Function_Reference/is_page

    So it has the same effect as using a different template, but without the cluttering effect they have.

  2. #12
    Jwrbloom is offline Hello World
    Join Date
    Feb 2010
    Posts
    28

    Default

    @itsananderson,

    My include code was:

    <?php
    include(ABSPATH . 'resources/profile.php');
    ?>


    @DD32,

    Do you think it's an issue of it being a Page and not a Post or an archive that relies on Post information? If not, my brain tells me I'll experience the same result.

    As far as I can tell, I"m using the same code I'm using on another site, obviously with a different database. It also, of course, has a different variable that I'm trying to use. I"m trying to pass the title of a Page so my code can use it to reference information from another data table within my WP database.

    That's what my brain tells me. :)

  3. #13
    itsananderson's Avatar
    itsananderson is offline Big Tipper
    Join Date
    Jan 2009
    Location
    Terre Haute, IN
    Posts
    354

    Default

    Well, silly question here, but there IS a profile.php in that resources folder, right? If so, have you checked that it's permissions are such that it can be included?

    I tried viewing http://spieceselect.org/resources/profile.php and got a not found error, which suggests to me that the file isn't there (could it be in a slightly different path?)

    After looking at your website, I think everyone is right that the solution you're using isn't the best. I don't think a page template is the way to go though. You've got some fun AJAX stuff going on that wouldn't be helped at all by a page template. I think a much better choice would be to use a shortcode to get your data into the post. These are also not very hard to implement, and I imagine several people here (myself included) could help you with it.

  4. #14
    Jwrbloom is offline Hello World
    Join Date
    Feb 2010
    Posts
    28

    Default

    In all the messing around with the INCLUDE, I did omit a level in the path. It should be:
    http://spieceselect.org/resources/2011/profile.php

    Of course I get the error:
    Fatal error: Call to undefined function get_query_var() in /home/jwrbloom/public_html/spieceselect.org/resources/2011/profile.php on line 3



  5. #15
    itsananderson's Avatar
    itsananderson is offline Big Tipper
    Join Date
    Jan 2009
    Location
    Terre Haute, IN
    Posts
    354

    Default

    Ahh, so now what's probably happening is the eval'd code is running outside the context of the rest of the request (which makes sense I guess). If that's what happening, it means that none of the functions or variables that WordPress defines will be available.

    Again, probably best to just use a Short Code here.

  6. #16
    Jwrbloom is offline Hello World
    Join Date
    Feb 2010
    Posts
    28

    Default

    But this code is working on my production site. Same pathway within that site's URL /resources/wp-playerProfile.php. It's place via an INCLUDE on my theme's Tag Archive.

    $wp_tagID = get_query_var('tag_id');


    mysql_select_db("jwrbloom_wpHHR");


    $query = 'SELECT * FROM wp_playerRank';
    $results = mysql_query($query);
    while($line = mysql_fetch_assoc($results)) {

  7. #17
    Otto's Avatar
    Otto is offline On The Rocks
    Join Date
    Apr 2009
    Location
    Memphis, TN
    Posts
    865

    Default

    Quote Originally Posted by Jwrbloom View Post
    In all the messing around with the INCLUDE, I did omit a level in the path. It should be:
    http://spieceselect.org/resources/2011/profile.php

    Of course I get the error:
    Fatal error: Call to undefined function get_query_var() in /home/jwrbloom/public_html/spieceselect.org/resources/2011/profile.php on line 3


    What does your include look like now?

    Again, you cannot include the http path. You need to include the ABSPATH one instead.

  8. #18
    Jwrbloom is offline Hello World
    Join Date
    Feb 2010
    Posts
    28

    Default

    The ABSPATH only gives me a much longer error, and I have used the HTTP in includes in multiple other locations successfully on my production site.

  9. #19
    Otto's Avatar
    Otto is offline On The Rocks
    Join Date
    Apr 2009
    Location
    Memphis, TN
    Posts
    865

    Default

    I don't care if it worked before... It's not going to work this time. Trust me, I do know what I'm talking about here. Including via HTTP doesn't include the code, it includes the output of the HTTP call, which is not code but the product of running that code. It's a bad idea and you should never, ever, include a URL.

    The ABSPATH way is the *only* way you're going to make this work properly. So you have to solve any new problems using that way.

    So if you get a new error, then give us that error. Just because the error is shorter doesn't make it a better error to have, you know...

  10. #20
    Jwrbloom is offline Hello World
    Join Date
    Feb 2010
    Posts
    28

    Default

    Fair enough, and I found a mistake on my part in the path using the ABSPATH.

    Here is the code I'm using. It's producing no errors now, but it is producing just the names of all the Pages, which I assume match the page_id. Instead, I just want it to produce the content that matches the applicable page.


    <?php

    $playerName = get_query_var('page_id');


    $con = mysql_connect("localhost","jwrbloom_","redcoach");

    mysql_select_db("jwrbloom_wpspselect", $con);

    $query = 'SELECT * FROM team2011 ORDER BY uniform ASC';
    $results = mysql_query($query);

    while($line = mysql_fetch_assoc($results)) {

    if ($playerName == $line['nameFirst'].'-'.$line['nameLast']) {

    echo '<div>' . $line['nameFirst'].' '.$line['nameLast'] . '</div>';

    }
    }
    ?>

    http://spieceselect.org

    From there, looking at the thumbnails below the Featured panel, click on the third one from the left, top row. I want it to just produce one name in the smaller white font, below the school name and position. Eventually, once we get this figured out, the data I'll echo is the school's address and coach's name.

Page 2 of 3 FirstFirst 123 LastLast

Posting Permissions

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