• How come this doesn’t work without grave accents but when i put them in it does?
    $wpdb->get_results("SELECT * FROM Tlogin WHERE key = 'heyy'");

    Im sure i have executed SQL commands without them in the past?

Viewing 6 replies - 1 through 6 (of 6 total)
  • The SQL WHERE clause requires the quotes for text values, but not for numeric values.

    I’d guess all your key values in the past have been numeric, but this may be the first time your key value has been text?

    Thread Starter toxinhead

    (@toxinhead)

    Sorry i am meaning “backticks” -> `

    They are around the Tlogin, and key
    Thanks

    Just to make sure I’m understanding correctly– are you saying you have to put backticks around both the table name and the column name in your SQL query in order to make it work?

    Thread Starter toxinhead

    (@toxinhead)

    Yeah exactly, just going over my old code again, i never had it. 🙂

    Okay, taking a wild guess on this, but . . . if get_results is invoking methods of the wpdb object, and it has to pass table names and column names into parameters for those methods . . . maybe then you need the backticks to get those names passed as if they were string literals?

    Like I said, I’m guessing– but I’m making that guess based on examples I’m seeing in the wpdb class reference. They seem to use variables instead of literal table names in some of the examples.

    Or maybe there’s some new code in the get_results that is doing prepare and/or sanitation on the parameters before performing the query?

    Thread Starter toxinhead

    (@toxinhead)

    Yea i think so too!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Random question about grave accent ` in SQL’ is closed to new replies.