sql error (3 posts)

  1. shadd
    Posted 6 years ago #

    Hi Guys

    I keep getting errors when executing the following query:

    $wpdb->get_row("SELECT * FROM alb_teachers WHERE teacher_name = $teacher_name");

    WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Abaa Alay' at line 1]
    SELECT * FROM alb_teachers WHERE teacher_name = Abaa Alay

    Here is the DB table:

    CREATE TABLE alb_teachers (
    teacher_id integer auto_increment NOT NULL,
    teacher_name varchar(120) NOT NULL,
    teacher_description text NULL,
    PRIMARY KEY(teacher_id)

  2. kymac
    Posted 6 years ago #

    Your teacher_name needs to be in quotes. I believe this will work:

    $wpdb->get_row("SELECT * FROM alb_teachers WHERE teacher_name = '$teacher_name'");

  3. shadd
    Posted 6 years ago #

    Thanks. BTW, does WP offer transaction committ and rollback ?

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.