WordPress.org

Support

Support » Plugins and Hacks » Shortcode Exec PHP » [Resolved] [Plugin: Shortcode Exec PHP] Error messages – how to interpret

[Resolved] [Plugin: Shortcode Exec PHP] Error messages – how to interpret

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Contributor M66B

    @m66b

    Since you didn’t post the code, I can only guess. ‘mysql_real_escape_string’ needs an open database connection to work (which is indeed a little counter-intuitive).

    Here is the code:

    extract(shortcode_atts(array('arg' => 'default'), $atts));
    
    $playerID = $arg;
    
    $dbbosfan = mysql_connect ("localhost", USERNAME, PASSWORD);
    if (!$dbbosfan){
    	die ('I cannot connect to the database because: ' . mysql_error());
    }
    
    mysql_select_db ("bosfan_redsox",$dbbosfan);
    
    $query = "SELECT * FROM playerdata pd WHERE pd.playerID = '$playerID'";
    $result = mysql_query($query,$dbbosfan) or die(mysql_error());
    $row = mysql_fetch_array($result);
    
    $p_name = $row['fullname'];
    $p_byy = $row['byy'];
    $p_bmm = $row['bmm2'];
    $p_bdd = $row['bdd'];
    $p_posID = $row['posID'];
    $p_pos = $row['pos'];
    
    $p_legend = FALSE;
    if ($row['legend'] == TRUE){
    	$p_legend = TRUE;
    }
    
    $p_soxhof = FALSE;
    if ($row['soxhof'] == TRUE){
    	$p_soxhof = TRUE;
    	$p_soxhofyear = $row['soxhofyear'];
    }
    
    $p_bbhof = FALSE;
    if ($row['bbhof'] == TRUE){
    	$p_bbhof = TRUE;
    	$p_bbhofyear = $row['bbhofyear'];
    }
    
    mysql_close($dbbosfan);
    
    print "  <p><strong>Date of Birth</strong>: ".$p_bdd." ".$p_bmm." ".$p_byy."<br/>\n";
    
    if ($p_soxhof = TRUE){
      print "    <strong>Elected to Red Sox Hall of Fame</strong>: ".$p_soxhofyear."<br/>\n";
    }
    
    if ($p_bbhof = TRUE){
      print "    <strong>Elected to Baseball Hall of Fame</strong>: ".$p_bbhofyear."<br/>\n";
    }
    
    print "  </p>\n\n";
    Plugin Contributor M66B

    @m66b

    Warning: mysql_real_escape_string(): 14 is not a valid MySQL-Link resource in /home/bosfan/public_html/onebostonfan/wp-includes/wp-db.php on line 787

    Warning: mysql_error(): 14 is not a valid MySQL-Link resource in /home/bosfan/public_html/onebostonfan/wp-includes/wp-db.php on line 1098

    It seems these errors are not related to the shortcode, look at the file names.

    Resolved it… apparently, it did not like the use of the mysql_close() fuction.

    So now when I remove the mysql_close() function, some of the other WP-specific widgets do not function. For example, on this page:

    PDATA Test Page

    The script runs, but then the sidebar widgets for the Categories and Tags show no output.

    My guess is that the opening of the SQL database separate from the QP SQL database is the culprit.

    Plugin Contributor M66B

    @m66b

    Is the database you are using in the script the WordPress database? If so, you should use the WordPress functions to access it.

    No, it’s a separate database.

    Plugin Contributor M66B

    @m66b

    Maybe you should re-select the WordPress database at the end of the script (mysql_select_db).

    Bingo! Thanks again, Marcel.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘[Resolved] [Plugin: Shortcode Exec PHP] Error messages – how to interpret’ is closed to new replies.
Skip to toolbar