Make WordPress Core

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#41929 closed defect (bug) (duplicate)

Bug wpdb prepare 4.8.2

Reported by: victorfreitas's profile victorfreitas Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.8.2
Component: Query Keywords:
Focuses: Cc:

Description

After updating to 4.8.2, my SQL query in prepare method not working.

Code example:

<?php
        $results = $wpdb->get_results(
                $wpdb->prepare(
                        "SELECT
                                `ID`
                         FROM
                                `{$wpdb->posts}`
                         WHERE
                                `ID` = %1\$d
                         AND
                                `post_status` = '%2\$s'
                        ",
                        100,
                        'publish'
                )
        );

Change History (2)

#1 follow-up: @ocean90
7 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Hello @victorfreitas, numbered placeholders are not supported by wpdb::prepare(), see #41926 and #41925.

#2 in reply to: ↑ 1 @victorfreitas
7 years ago

Replying to ocean90:

Thank you @ocean90 for the feedback.

Note: See TracTickets for help on using tickets.