SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Jan 2005
    Posts
    79
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Can someone help?

    Hello,

    I run this query:

    $result = mysql_query("SELECT pin FROM tblGsm WHERE gsmtype ='$gsmtype' AND amount='$amount' LIMIT 1") or exit('Returned Error: '.mysql_error());
    echo mysql_num_rows($result)." rows were returned for query 'SELECT pin FROM tblGsm WHERE gsmtype ='$gsmtype' AND amount='$amount' LIMIT 1'<br>";
    $pin=mysql_result($result, 0);
    mysql_query('DELETE FROM tblGsm WHERE pin='.$pin);

    I get:

    #1064 - 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 '$result = mysql_query("SELECT pin FROM tblGsm WHERE gsmtype ='$

    Can't spot where the error is:

  2. #2
    SitePoint Wizard guelphdad's Avatar
    Join Date
    Oct 2003
    Location
    St. Catharines, ON Canada
    Posts
    1,708
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think but I'm not sure that you will need to use backticks around your columname pin like so `pin`. IN is a reserved word in mysql, I'm guessing that mysql is thinking you mean:
    Code:
     SELECT P IN
    and thus thinks you have a syntax error because the two are running together.

    See if that helps you.

  3. #3
    SitePoint Enthusiast
    Join Date
    Jan 2005
    Posts
    79
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello,

    Thanks. The script is ok. I just discovered that I used the wrong variable.

    Thanks Dave L.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •