Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: ERROR syntax to use near

  1. #1
    Join Date
    Sep 2007
    Posts
    83
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default ERROR syntax to use near

    I dont unstand what its telling me, can someone see my 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 ''' LIMIT 5' at line 1

    PHP Code:
    $query = "SELECT * FROM Entry_Form WHERE AttendRound'".$_POST['AttendRound']."' LIMIT 5";
    $result = mysql_query($query) or die(mysql_error());
    $row = mysql_fetch_array($result) or die(mysql_error());

    ?>

    <?php echo $row['Attend_Round']; ?><br><?php echo $row['Name']; ?><br><?php echo $row['Eighth_Scale_Buggy']; ?> <?php echo $row['Eighth_Scale_Sportsman']; ?> <?php echo $row['Arena_Truck']; ?> <?php echo $row['Monster_Truck']; ?>

  2. #2
    Join Date
    Jan 2007
    Posts
    629
    Thanks
    10
    Thanked 28 Times in 28 Posts

    Default

    The error is saying that there is a problem near your LIMIT syntax. One problem is the lack of an equal sign (=). I think it also wants LIMIT 0, 5 rather then LIMIT 5, but I don't know. Look at the proper syntax in your manual

    Try this:
    Code:
    "SELECT * FROM Entry_Form WHERE AttendRound = '".$_POST['AttendRound']."' LIMIT 0, 5";
    Last edited by Jas; 01-16-2008 at 07:37 PM.
    --Jas
    function GreatMinds(){ return "Think Like Jas"; }
    I'm gone for a while, but in the meantime: Try using my FTP script | Fight Bot Form Submissions

  3. #3
    Join Date
    Sep 2007
    Posts
    83
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by Jas View Post
    The error is saying that there is a problem near your LIMIT syntax. One problem is the lack of an equal sign (=). I think it also wants LIMIT 0, 5 rather then LIMIT 5, but I don't know. Look at the proper syntax in your manual

    Try this:
    Code:
    "SELECT * FROM Entry_Form WHERE AttendRound = '".$_POST['AttendRound']."' LIMIT 0, 5";
    then I get this
    Unknown column 'AttendRound' in 'where clause'

  4. #4
    Join Date
    Jan 2007
    Posts
    629
    Thanks
    10
    Thanked 28 Times in 28 Posts

    Default

    You must have misspelled the name of the column. MySQL doesn't know where your trying to look. Find the correct name of the column in PHPMyAdmin (in wamp).
    --Jas
    function GreatMinds(){ return "Think Like Jas"; }
    I'm gone for a while, but in the meantime: Try using my FTP script | Fight Bot Form Submissions

  5. #5
    Join Date
    Sep 2007
    Posts
    83
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    you are right misspelled now I dont get the errors, but nothing is echoed just a blank page

  6. #6
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Just to see if you are getting any results, add this line somewhere after the query to the database is made.

    Code:
    echo 'Total Rows: '.mysql_num_rows($result);
    If you get nothing, then the query to the db is not pulling any results. If you get a number, then the query is right, but the way you call the data is wrong (if that makes sense).

    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  7. #7
    Join Date
    Sep 2007
    Posts
    83
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I get a blank page still (see here)
    PHP Code:
    mysql_connect(localhost,$username,$password);
    @mysql_select_db($database) or die( "Unable to select database");
    mysql_query($query);
    $query = "SELECT * FROM Entry_Form WHERE Attend_Round = '".$_POST['AttendRound']."' LIMIT 0, 5";
    $result = mysql_query($query) or die(mysql_error());
    $row = mysql_fetch_array($result) or die(mysql_error());
    echo 'Total Rows: '.mysql_num_rows($result);
    ?>

    <?php echo $row['Attend_Round']; ?><br><?php echo $row['Name']; ?><br><?php echo $row['Eighth_Scale_Buggy']; ?> <?php echo $row['Eighth_Scale_Sportsman']; ?> <?php echo $row['Arena_Truck']; ?> <?php echo $row['Monster_Truck']; ?>

  8. #8
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Well, apparently the page stops at this line in the source code:

    Code:
    <body style="font-size: 11pt">
    After that, there is nothing else. Is this code executed after that line or is there any other code that would be stopping the source from executing?

    Also, in your code, you have the following that does not need to be in there (the highlighted part):

    Code:
    mysql_connect(localhost,$username,$password);
    @mysql_select_db($database) or die( "Unable to select database");
    mysql_query($query);
    $query = "SELECT * FROM Entry_Form WHERE Attend_Round = '".$_POST['AttendRound']."' LIMIT 0, 5";
    $result = mysql_query($query) or die(mysql_error());
    $row = mysql_fetch_array($result) or die(mysql_error());
    echo 'Total Rows: '.mysql_num_rows($result);
    ?>
    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  9. #9
    Join Date
    Sep 2007
    Posts
    83
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Ive tried all kinds of differant stuff and nothing

    HTML Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Entries Page</title>
    <meta name="robots" content="index, follow">
    <meta name="revisit-after" content="1 Week">
    <meta name="language" content="EN">
    <meta name="rating" content="general">
    <meta name="robots" content="all">
    <meta http-equiv="Content-Language" content="en-us">
    <meta http-equiv="imagetoolbar" content="no">
    
    <style type="text/css">
    html, body{
    scrollbar-base-color: #F5F5F5;
    scrollbar-arrow-color: #000AC9;
    scrollbar-3dlight-color: #f2f2f3;
    scrollbar-darkshadow-color: #dcdcdd;
    scrollbar-face-color: #f2f2f3;
    scrollbar-highlight-color: #efefef;
    scrollbar-shadow-color: #d4d4d4;
    scrollbar-track-color: #FFFFFF;
    }
    
    </style>
      </head>
    <body style="font-size: 11pt">
    
    <?php
    
    mysql_connect(localhost,$username,$password);
    @mysql_select_db($database) or die( "Unable to select database");
    
    $query = "SELECT * FROM Entry_Form WHERE Attend_Round = '".$_POST['AttendRound']."' LIMIT 0, 5";
    $result = mysql_query($query) or die(mysql_error());
    $row = mysql_fetch_array($result) or die(mysql_error());
    echo 'Total Rows: '.mysql_num_rows($result);
    ?>
    
    <?php echo $row['Attend_Round']; ?><br><?php echo $row['Name']; ?><br><?php echo $row['Eighth_Scale_Buggy']; ?> <?php echo $row['Eighth_Scale_Sportsman']; ?> <?php echo $row['Arena_Truck']; ?> <?php echo $row['Monster_Truck']; ?>
    
      </body>
    </html>

  10. #10
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Try this and see if it works for you. As you can see, I trimmed the code to just the body tags, but don't do this when you make your new file as I simply did this to save space.

    Code:
    <body style="font-size: 11pt">
    
    <?php
    
    mysql_connect(localhost,$username,$password);
    mysql_select_db($database) or die( "Unable to select database");
    
    $query = "SELECT * FROM `Entry_Form` WHERE `Attend_Round` = '".$_POST['AttendRound']."' LIMIT 5";
    
    $result = mysql_query($query) or die(mysql_error());
    
     if (!mysql_num_rows($result)) {
       die('No Results Found!');
     }
    
     else {
      while ($row = mysql_fetch_array($result)) {
    ?>
    
    <?php echo $row['Attend_Round']; ?><br><?php echo $row['Name']; ?><br><?php echo $row['Eighth_Scale_Buggy']; ?> <?php echo $row['Eighth_Scale_Sportsman']; ?> <?php echo $row['Arena_Truck']; ?> <?php echo $row['Monster_Truck']; ?>
    
    <hr>
    <?php
      }
     }
    ?>
      </body>
    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

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
  •