"Unknown column test3 in field list" error in MySQL

Discussion in 'Web Design and Development' started by MythicFrost, Jun 20, 2010.

  1. MythicFrost macrumors 68040

    MythicFrost

    Joined:
    Mar 11, 2009
    Location:
    Australia
    #1
    Hi,

    I'm trying to do this:
    Code:
    $sqlAdd[$i] = "INSERT INTO ct_".$country." (name, url) VALUES (test3, test)";
    if (!mysql_query(mysql_real_escape_string($sqlAdd[$i]), $con)) {
        die('Error: ' . mysql_error());
    }
    (adding into the table ct_int in the field name and url rows, the values test3 and test)

    The error I get is:
    How come its looking for column "test" it should be looking for the column "name"? What's up with that ey?

    Kind Regards
     
  2. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #2
    Values should be strings, which need to be quoted.

    PHP:
    $sqlAdd[$i] = "INSERT INTO ct_".$country." (name, url) VALUES ('test3', 'test')";
    which will put "test3" into column name, and "test" into column url.
     

Share This Page