Make WordPress Core


Ignore:
Timestamp:
01/30/2004 02:39:01 AM (23 years ago)
Author:
alex_t_king
Message:

added single quotes around values in SQL statements

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/functions.php

    r779 r810  
    413413        global $wpdb, $cache_userdata, $use_cache, $tableusers;
    414414        if ((empty($cache_userdata[$userid])) || (!$use_cache)) {
    415                 $user = $wpdb->get_row("SELECT * FROM $tableusers WHERE ID = $userid");
     415                $user = $wpdb->get_row("SELECT * FROM $tableusers WHERE ID = '$userid'");
    416416        $user->user_nickname = stripslashes($user->user_nickname);
    417417        $user->user_firstname = stripslashes($user->user_firstname);
    … …  
    465465function get_usernumposts($userid) {
    466466        global $tableposts, $tablecomments, $wpdb;
    467         return $wpdb->get_var("SELECT COUNT(*) FROM $tableposts WHERE post_author = $userid");
     467        return $wpdb->get_var("SELECT COUNT(*) FROM $tableposts WHERE post_author = '$userid'");
    468468}
    469469
    … …  
    528528
    529529        // Otherwise, build a WHERE clause, making the values safe along the way:
    530         if ($year) $where .= " AND YEAR(post_date) = " . intval($year);
    531         if ($monthnum) $where .= " AND MONTH(post_date) = " . intval($monthnum);
    532         if ($day) $where .= " AND DAYOFMONTH(post_date) = " . intval($day);
     530        if ($year) $where .= " AND YEAR(post_date) = '" . intval($year) . "'";
     531        if ($monthnum) $where .= " AND MONTH(post_date) = '" . intval($monthnum) . "'";
     532        if ($day) $where .= " AND DAYOFMONTH(post_date) = '" . intval($day) . "'";
    533533        if ($postname) $where .= " AND post_name = '" . $wpdb->escape($postname) . "' ";
    534534
    … …  
    585585        global $post, $tableusers, $tablecategories, $tableposts, $tablecomments, $wpdb;
    586586
    587         $post = $wpdb->get_row("SELECT * FROM $tableposts WHERE ID = $postid");
     587        $post = $wpdb->get_row("SELECT * FROM $tableposts WHERE ID = '$postid'");
    588588       
    589589        $postdata = array (
    … …  
    630630        global $postc,$id,$commentdata,$tablecomments, $wpdb;
    631631        if ($no_cache) {
    632                 $query = "SELECT * FROM $tablecomments WHERE comment_ID = $comment_ID";
     632                $query = "SELECT * FROM $tablecomments WHERE comment_ID = '$comment_ID'";
    633633                if (false == $include_unapproved) {
    634634                    $query .= " AND comment_approved = '1'";
    … …  
    681681                        SELECT category_id
    682682                        FROM  $tablecategories, $tablepost2cat
    683                         WHERE $tablepost2cat.category_id = cat_ID AND $tablepost2cat.post_id = $post->ID
     683                        WHERE $tablepost2cat.category_id = cat_ID AND $tablepost2cat.post_id = '$post->ID'
    684684                        ");
    685685        } else {
    … …  
    938938        @fclose($fs);
    939939
    940         $wpdb->query("UPDATE $tableposts SET pinged = CONCAT(pinged, '\n', '$tb_url') WHERE ID = $ID");
    941         $wpdb->query("UPDATE $tableposts SET to_ping = REPLACE(to_ping, '$tb_url', '') WHERE ID = $ID");
     940        $wpdb->query("UPDATE $tableposts SET pinged = CONCAT(pinged, '\n', '$tb_url') WHERE ID = '$ID'");
     941        $wpdb->query("UPDATE $tableposts SET to_ping = REPLACE(to_ping, '$tb_url', '') WHERE ID = '$ID'");
    942942        return $result;
    943943}
Note: See TracChangeset for help on using the changeset viewer.