Trouble with sql query

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Fernando Rodríguez

    Trouble with sql query


    Hi,

    I'm sending the follwoing query to mysql from a php script:

    ----------------------------------------------------------------------------------------
    INSERT INTO affiliates (aff_id,
    first_name, last_name, main_site_url, monthly_unique_ visitors,
    email_address, phone_number, address, address2, city, state_or_provin ce,
    zip_code, country, payment_thresho ld, license_to_spam , password, is_active,
    signup_date)
    VALUES ( `tester` , `Fernando` , `Rodríguez Romero` , `http://www.easyjob.net `
    , `100-999` , `yada@easyjob.n et` , `+34 91 8130869` , `Arturo Soria, 339
    P2 2Izq` , `` , `Madrid` , `Madrid` , `28033` , `Spain` , 100, 1, `1492549`
    , 1,2006-01-23)
    ---------------------------------------------------------------------------------------

    And I always get this error:

    ------------------------------------------
    Unknown column 'tester' in 'field list'
    ------------------------------------------

    I don't get it. What am I doing wrong? O:-)

    Thanks!

    BTW, the table affiliates is as follows:



    CREATE TABLE affiliates(
    code INT UNSIGNED NOT NULL AUTO_INCREMENT,
    id VARCHAR(40) NOT NULL,
    first_name VARCHAR(255) NOT NULL,
    last_name VARCHAR(255) NOT NULL,
    main_site_url VARCHAR(255),
    monthly_unique_ visitors VARCHAR(25),
    company_name VARCHAR(255),
    email_address VARCHAR(100) NOT NULL,
    phone_number VARCHAR(100) NOT NULL,
    address VARCHAR(255) NOT NULL,
    address2 VARCHAR(255),
    city VARCHAR(255) NOT NULL,
    state_or_provin ce VARCHAR(255),
    zip_code VARCHAR(25) NOT NULL,
    country VARCHAR(100) NOT NULL,
    payment_thresho ld INT UNSIGNED DEFAULT 100 NOT NULL,
    commission FLOAT DEFAULT 0.4 NOT NULL,
    license_to_spam TINYINT DEFAULT 1 NOT NULL,
    is_active TINYINT DEFAULT 1 NOT NULL,
    signup_date DATE NOT NULL,
    password VARCHAR(40),
    comments MEDIUMTEXT,
    PRIMARY KEY (code),
    UNIQUE UC_id (id),
    INDEX IDX_affiliates_ 1 (id,email_addre ss,is_active,li cense_to_spam,c ommission,signu p_date),
    FULLTEXT IDX_affiliates_ 2 (comments));


  • Jerry Stuckle

    #2
    Re: Trouble with sql query

    Fernando Rodríguez wrote:[color=blue]
    >
    > Hi,
    >
    > I'm sending the follwoing query to mysql from a php script:
    >
    > ----------------------------------------------------------------------------------------
    >
    > INSERT INTO affiliates (aff_id, first_name, last_name,
    > main_site_url, monthly_unique_ visitors, email_address,
    > phone_number, address, address2, city, state_or_provin ce,
    > zip_code, country, payment_thresho ld, license_to_spam ,
    > password, is_active, signup_date) VALUES ( `tester` ,
    > `Fernando` , `Rodríguez Romero` , `http://www.easyjob.net ` , `100-999` ,
    > `yada@easyjob.n et` , `+34 91 8130869` , `Arturo Soria, 339 P2 2Izq` , ``
    > , `Madrid` , `Madrid` , `28033` , `Spain` , 100, 1, `1492549` ,
    > 1,2006-01-23)
    > ---------------------------------------------------------------------------------------
    >
    >
    > And I always get this error:
    >
    > ------------------------------------------
    > Unknown column 'tester' in 'field list'
    > ------------------------------------------
    >
    > I don't get it. What am I doing wrong? O:-)
    >
    > Thanks!
    >
    > BTW, the table affiliates is as follows:
    >
    >
    >
    > CREATE TABLE affiliates(
    > code INT UNSIGNED NOT NULL AUTO_INCREMENT,
    > id VARCHAR(40) NOT NULL,
    > first_name VARCHAR(255) NOT NULL,
    > last_name VARCHAR(255) NOT NULL,
    > main_site_url VARCHAR(255),
    > monthly_unique_ visitors VARCHAR(25),
    > company_name VARCHAR(255),
    > email_address VARCHAR(100) NOT NULL,
    > phone_number VARCHAR(100) NOT NULL,
    > address VARCHAR(255) NOT NULL,
    > address2 VARCHAR(255),
    > city VARCHAR(255) NOT NULL,
    > state_or_provin ce VARCHAR(255),
    > zip_code VARCHAR(25) NOT NULL,
    > country VARCHAR(100) NOT NULL,
    > payment_thresho ld INT UNSIGNED DEFAULT 100 NOT NULL,
    > commission FLOAT DEFAULT 0.4 NOT NULL,
    > license_to_spam TINYINT DEFAULT 1 NOT NULL,
    > is_active TINYINT DEFAULT 1 NOT NULL,
    > signup_date DATE NOT NULL,
    > password VARCHAR(40),
    > comments MEDIUMTEXT,
    > PRIMARY KEY (code),
    > UNIQUE UC_id (id),
    > INDEX IDX_affiliates_ 1
    > (id,email_addre ss,is_active,li cense_to_spam,c ommission,signu p_date),
    > FULLTEXT IDX_affiliates_ 2 (comments));
    >
    >[/color]

    You're using a back-tickie (`) before tester. Character values are
    surrounded by single quotes (').

    And BTW - this is NOT a PHP question and shouldn't have been
    cross-posted to comp.lang.php.

    --
    =============== ===
    Remove the "x" from my email address
    Jerry Stuckle
    JDS Computer Training Corp.
    jstucklex@attgl obal.net
    =============== ===

    Comment

    • Iván Sánchez Ortega

      #3
      Re: Trouble with sql query

      -----BEGIN PGP SIGNED MESSAGE-----
      Hash: SHA1

      Fernando Rodredguez wrote:
      [color=blue]
      > ------------------------------------------
      > Unknown column 'tester' in 'field list'
      > ------------------------------------------
      >
      > I don't get it. What am I doing wrong? O:-)[/color]

      Use single quotes (''') , no back-quotes* (```) in your query.


      * (Is the name of the ` symbol "back-quote"? I'm not sure right now)

      - --
      - ----------------------------------
      Iván Sánchez Ortega -i-punto-sanchez--arroba-mirame-punto-net

      Jugué con quien no sabía y me llevó cuanto tenía.

      -----BEGIN PGP SIGNATURE-----
      Version: GnuPG v1.4.2 (GNU/Linux)

      iD8DBQFD1S1y3jc Q2mg3Pc8RAswuAJ sE6IrALpd4idQdL qZYhPWLTYUwVwCe NgpG
      1fhvH/jdsUgkix0toFzE6 To=
      =e1Yo
      -----END PGP SIGNATURE-----

      Comment

      • Jon

        #4
        Re: Trouble with sql query

        single quotes won't work either - aff_id is most likely an INT, so using
        quotes of any kind to insert data will likely blow it up. Try it without the
        tick marks or single quotes.

        "Iván Sánchez Ortega" <i.punto.sanche z--@rroba--mirame.punto.ne t> wrote in
        message news:85nfa3-2ig.ln1@blacksp ark.escomposlin ux.org...[color=blue]
        > -----BEGIN PGP SIGNED MESSAGE-----
        > Hash: SHA1
        >
        > Fernando Rodredguez wrote:
        >[color=green]
        >> ------------------------------------------
        >> Unknown column 'tester' in 'field list'
        >> ------------------------------------------
        >>
        >> I don't get it. What am I doing wrong? O:-)[/color]
        >
        > Use single quotes (''') , no back-quotes* (```) in your query.
        >
        >
        > * (Is the name of the ` symbol "back-quote"? I'm not sure right now)
        >
        > - --
        > - ----------------------------------
        > Iván Sánchez Ortega -i-punto-sanchez--arroba-mirame-punto-net
        >
        > Jugué con quien no sabía y me llevó cuanto tenía.
        >
        > -----BEGIN PGP SIGNATURE-----
        > Version: GnuPG v1.4.2 (GNU/Linux)
        >
        > iD8DBQFD1S1y3jc Q2mg3Pc8RAswuAJ sE6IrALpd4idQdL qZYhPWLTYUwVwCe NgpG
        > 1fhvH/jdsUgkix0toFzE6 To=
        > =e1Yo
        > -----END PGP SIGNATURE-----[/color]


        Comment

        • Iván Sánchez Ortega

          #5
          Re: Trouble with sql query

          -----BEGIN PGP SIGNED MESSAGE-----
          Hash: SHA1

          Jon wrote:
          [color=blue]
          > single quotes won't work either - aff_id is most likely an INT, so using
          > quotes of any kind to insert data will likely blow it up. Try it without
          > the tick marks or single quotes.[/color]

          The table mixes string and numeric columns - and single quotes are needed in
          the string (varchar) columns.



          Fernando, tío, usa comillas simples en la query. Esa tecla que hay al lado
          del cero. Ah, y gracias por poner tu teléfono y dirección, cosa que nunca
          deberías haber hecho por tu propia seguridad.


          - --
          - ----------------------------------
          Iván Sánchez Ortega -i-punto-sanchez--arroba-mirame-punto-net

          http://acm.asoc.fi.upm.es/~mr/ ; http://acm.asoc.fi.upm.es/~ivan/
          MSN:i_eat_s_p_a _m_for_breakfas t@hotmail.com
          Jabber:ivansanc hez@jabber.org ; ivansanchez@kde talk.net
          -----BEGIN PGP SIGNATURE-----
          Version: GnuPG v1.4.2 (GNU/Linux)

          iD8DBQFD1XO/3jcQ2mg3Pc8RArs bAJ9i402UkgMStO 0++awrPGthTK3xc ACfYFqh
          18mjpr24J2Zd8+H ynjtCya4=
          =6SbO
          -----END PGP SIGNATURE-----

          Comment

          • Jerry Stuckle

            #6
            Re: Trouble with sql query

            Jon wrote:[color=blue]
            > single quotes won't work either - aff_id is most likely an INT, so using
            > quotes of any kind to insert data will likely blow it up. Try it without the
            > tick marks or single quotes.
            >[/color]


            Nope. aff_id evidently is a character type, and he's trying to insert
            the value 'tester'. He just has back tickies around tester.

            And please don't top post.

            --
            =============== ===
            Remove the "x" from my email address
            Jerry Stuckle
            JDS Computer Training Corp.
            jstucklex@attgl obal.net
            =============== ===

            Comment

            Working...