WordPress.org

Ready to get started?Download WordPress

Forums

Call to an undefined function??? (9 posts)

  1. Jim R
    Member
    Posted 4 years ago #

    Here is the error:
    Call to undefined function get_query_var()

    Here is the code I'm using:

    <?php
    
    $playerName = get_query_var('the_title'); 
    
    var_dump($playerName);
    
    $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>';
    
    	}
    }
    ?>
  2. MichaelH
    Member
    Posted 4 years ago #

  3. Jim R
    Member
    Posted 4 years ago #

    That really doesn't help me. I'm not trying to integrate WordPress into my site. It is my site. I'm trying to add information from my own data table within my WP database onto Pages with an include statement.

  4. MichaelH
    Member
    Posted 4 years ago #

    Thanks for that additional information. So you are putting that code in a valid Page Template in your theme folder?

    Note: if those tables are in your WordPress database you can use the wpdb class to access those tables.

  5. Jim R
    Member
    Posted 4 years ago #

    Sorry for not providing more information. I was pasting that in just before leaving for the day, and my response last night was not complete.

    No, I'm including it via PHP tags where you add a Page to WP. I do have PHP exec, and I use that code in another site, just with a different echo output and different variable for get_query_var. It works like a charm. Even in getting some of the syntax right, I never got an undefined error.

    From that site to this one, it was pretty much a copy/paste, just changing the variable. The difference is the other site is the INCLUDE is hard coded on the Tag Archive PHP file, tag.php. This one, the INCLUDE is where you enter text.

    However, keep in mind, I'm using another INCLUDE on a Page that queries another data table. Now that I mention it, I haven't checked that structure yet.

  6. MichaelH
    Member
    Posted 4 years ago #

    Using the WordPress Default theme, with this plugin:
    http://wordpress.org/extend/plugins/exec-php/

    with this in wp-content/themes/default/playername.php

    <?php
    $pageid = get_query_var('page_id');
    echo '$page_id is ' . $pageid;
    ?>

    and this in the page content

    <?php
    include (ABSPATH . "wp-content/themes/default/playername.php")
    ?>

    display the page id of the viewed page.

  7. Jim R
    Member
    Posted 4 years ago #

    I just put that on my profile.php page, same error.

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

  8. Jim R
    Member
    Posted 4 years ago #

    Now I put what you told me my themes folder. Here is what I get...

    Warning: include(ABSPATH . wp-content/themes/TheCorporation/profile.php) [function.include]: failed to open stream: No such file or directory in /home/jwrbloom/public_html/spieceselect.org/wp-content/plugins/php_execution/includes/class.php_execution.php(270) : eval()’d code on line 2 Warning: include(ABSPATH . wp-content/themes/TheCorporation/profile.php) [function.include]: failed to open stream: No such file or directory in /home/jwrbloom/public_html/spi

  9. Jim R
    Member
    Posted 4 years ago #

    I now have it so there are no errors. I had a path to URL issue. I just want to pass the information from the current page. I'm getting all the page name that match fields in my data table. I just want the current page info so I can match it to my data table and produce the desired results.

    Here is the page in question:
    http://spieceselect.org/dwight-cliff/

    Here is the code.

    <?php
    
    $playerName = get_query_var('page_id'); 
    
    echo '$page_id is ' . $playerName;
    
    $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>';
    
    	}
    }
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.