Page 3 of 3 FirstFirst 123
Results 21 to 27 of 27

Thread: Call to an undefined function???

  1. #21
    Jwrbloom is offline Hello World
    Join Date
    Feb 2010
    Posts
    28

    Default

    I made some progress, kind of:

    http://spieceselect.org

    Ok...here is a weird one. On a Page post, I have added the following INCLUDE:

    Code:
    <?php
    include (ABSPATH . "resources/2011/profile.php");
    ?>
    The code in that file is:

    Code:
    <?php
    
    $page_data = get_page($page_id);
    
    $playerName = $page_data->post_title;
     
    
    $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>';
            
        }
    }
    ?>
    On the Pages the INCLUDE is included, it causes the thumbnail on the Home Page to disappear, and when that entry is active in the Feature Slider, the "Read Now" link links back to the URL, not that Page.

    If you visit the intended URL, it all looks good: http://spieceselect.org/dwight-cliff


    However, when you remove this...

    Code:
    $page_data = get_page($page_id);
    ...the thumbnails return to the Home Page and the proper link is active on the Read Now button. Of course the intent of the INCLUDE doesn't work (right now just a test echo), which is a problem. Essentially, when it's all working, it will echo data from a separate data table about each player.

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

    Default

    I think you're might be overwriting a variable that WordPress needs to display the page.

    To reduce frustration for all parties involved, I'm just gonna go ahead and post a shortcode plugin that you can use to do EXACTLY what you're attempting using shortcodes.

    PHP Code:
    <?php
    /*
     Plugin Name: Simple Shortcode
     Plugin Author: Will Anderson
     Plugin URI: http://www.itsananderson.com/
     */

    // Usage:
    // [player name='First-Last' /]
    function handle_player($atts = array(), $content null) {
        
    $playerName addslashes($atts['name']);
        
    $con mysql_connect("localhost","jwrbloom_","redcoach");
        
    mysql_select_db("jwrbloom_wpspselect"$con);
        
    $query "SELECT * FROM team2011 WHERE CONCAT(nameFirst, '-', nameLast) = '$playerName' ORDER BY uniform ASC";
        
    $results mysql_query($query);

        while(
    $line mysql_fetch_assoc($results)) {
            echo 
    '<div>' $line['nameFirst'].' '.$line['nameLast'] . '</div>';
        }
    }

    add_shortcode('player''handle_player');
    ?>
    If you install this bad boy, you'll just need to go into your player pages and add the following code to get the appropriate player info.

    Code:
    [player name="First-Last" /]
    of course, replace the first and last name here with the actual first and last name of the player on each page.

    You'll probably need to hack the plugin code a little to get it to display exactly what you need, but I've given you all the structure need.

    please somebody (Otto) correct me if any part of this is incorrect.
    Last edited by itsananderson; 03-18-2010 at 08:56 PM.

  3. #23
    Jwrbloom is offline Hello World
    Join Date
    Feb 2010
    Posts
    28

    Default

    I get this error:

    Code:
    Warning: Cannot modify header information - headers already sent by (output started at /home/jwrbloom/public_html/spieceselect.org/wp-content/plugins/profile-query.php:1) in /home/jwrbloom/public_html/spieceselect.org/wp-includes/pluggable.php on line 868

    It shut the whole site down. I had to delete the file from the server.


    I'm just curious how what I had could work on the actual page itself but not in what the Home Page uses from that page.
    Last edited by Jwrbloom; 03-18-2010 at 09:59 PM.

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

    Default

    Oops. Should have returned the content rather than outputting it.

    Sorry about that. Give this a try.

    PHP Code:
    <?php
    /*
     Plugin Name: Simple Shortcode
     Plugin Author: Will Anderson
     Plugin URI: http://www.itsananderson.com/
     */

    // Usage:
    // [player name='First-Last' /]
    function handle_player($atts = array(), $content null) {
        
    $playerName addslashes($atts['name']);
        
    $con mysql_connect("localhost","jwrbloom_","redcoach");
        
    mysql_select_db("jwrbloom_wpspselect"$con);
        
    $query "SELECT * FROM team2011 WHERE CONCAT(nameFirst, '-', nameLast) = '$playerName' ORDER BY uniform ASC";
        
    $results mysql_query($query);
        
    $response ''
        
    while($line mysql_fetch_assoc($results)) {
            
    $response .= '<div>' $line['nameFirst'].' '.$line['nameLast'] . '</div>';
        }
    }

    add_shortcode('player''handle_player');
    ?>

  5. #25
    Jwrbloom is offline Hello World
    Join Date
    Feb 2010
    Posts
    28

    Default

    Same error:

    Warning: Cannot modify header information - headers already sent by (output started at /home/jwrbloom/public_html/spieceselect.org/wp-content/plugins/profile-query.php:1) in /home/jwrbloom/public_html/spieceselect.org/wp-includes/pluggable.php on line 868


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

    Default

    I changed get_page to get_post in the code that I had written, and it appears to be working.

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

    Default

    Ok, not sure why my code was throwing that error, but at least you got yours working.

Page 3 of 3 FirstFirst 123

Posting Permissions

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