PDA

View Full Version : ERROR syntax to use near



big-dog1965
01-16-2008, 05:05 AM
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


$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']; ?>

Jas
01-16-2008, 06:29 PM
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:

"SELECT * FROM Entry_Form WHERE AttendRound = '".$_POST['AttendRound']."' LIMIT 0, 5";

big-dog1965
01-16-2008, 07:19 PM
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:

"SELECT * FROM Entry_Form WHERE AttendRound = '".$_POST['AttendRound']."' LIMIT 0, 5";

then I get this
Unknown column 'AttendRound' in 'where clause'

Jas
01-16-2008, 08:18 PM
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).

big-dog1965
01-16-2008, 08:32 PM
you are right misspelled now I dont get the errors, but nothing is echoed just a blank page

thetestingsite
01-16-2008, 08:41 PM
Just to see if you are getting any results, add this line somewhere after the query to the database is made.



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.

big-dog1965
01-16-2008, 08:50 PM
I get a blank page still (see here (http://www.ksproseries.com/detail_entryform_pg.php))

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']; ?>

thetestingsite
01-16-2008, 08:54 PM
Well, apparently the page stops at this line in the source 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):



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.

big-dog1965
01-16-2008, 09:01 PM
Ive tried all kinds of differant stuff and nothing


<!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>

thetestingsite
01-16-2008, 09:09 PM
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.



<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.

big-dog1965
01-16-2008, 09:21 PM
I get no results found now, but I know there are 2 records in the DB

thetestingsite
01-16-2008, 10:24 PM
Something completely overlooked, but how are you getting the value of $_POST['AttendRound']? In order to get this, you need to send the request using the POST method with the variable AttendRound. Now are you just trying to list all of the items in the db or do you want to specify what results get pulled? If the first, simply use the following for your query:



$query = "SELECT * FROM `Entry_Form` LIMIT 5";


Hope this helps.