SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Guru adammc's Avatar
    Join Date
    Aug 2004
    Location
    Cairns, Australia
    Posts
    762
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Help debugging query

    Hi guys,

    Can anyone possibly help me debug this query?


    PHP Code:
        // Get the partner details
            
    $query "SELECT p_username, contact_person, FROM partners WHERE p_username='$_SESSION[p_username]'";        
            
    $result = @mysql_query ($query)  or die("<b>A fatal MySQL error occured</b>.\n<br />Query: " $query "<br />\nError: (" mysql_errno() . ") " mysql_error());
            while(
    $row=mysql_fetch_array($result)) 
               { 


    A fatal MySQL error occured.
    Query: SELECT p_username, contact_person, FROM partners WHERE p_username='aaaaaa'
    Error: (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 'FROM partners WHERE p_username='aaaaa'' at line 1

  2. #2
    SitePoint Enthusiast
    Join Date
    Aug 2005
    Location
    Perth, Australia
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    remove the comma after contact_person

  3. #3
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,350
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    exactly where the error message said to look
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  4. #4
    SitePoint Guru adammc's Avatar
    Join Date
    Aug 2004
    Location
    Cairns, Australia
    Posts
    762
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by rodp View Post
    remove the comma after contact_person
    Thank you soo much, I totaly missed that typo

  5. #5
    SitePoint Guru adammc's Avatar
    Join Date
    Aug 2004
    Location
    Cairns, Australia
    Posts
    762
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by r937 View Post
    exactly where the error message said to look
    The error states " 'FROM "....
    So if the typo had have been " SELECT p_username,, " (double comma) I would get an error saying:

    for the right syntax to use near 'contact_person, ???


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
  •