Help - Search - Members - Calendar
Full Version: You Have An Error In Your Sql Syntax
Zymic Webmaster Forums > Zymic Free Web Hosting > Databases & MySQL
jono99
Hi there,

I've recently started a site using PHP and MySQL but its not one of my strong points. I've written a script to insert some values into a table
but i'm getting the following error:

QUOTE
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 ' '', , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,' at line 1


This is my script/query:

CODE
$query="SELECT MAX(`PersonID`) FROM `rugby_people`";
$result=mysqli_query($con,$query)
    or die ("Couldn't execute query 3");
    
    while ($row = mysqli_fetch_array($result))
    {
        $personID = $row['1'];
    }
    
$query="INSERT INTO rugby_player_data (PersonID, PrimaryPosition, Aggression, Anticipation, Bravery, Consistency, Creativity, Decisions, Dirtiness, Flair, ImportantMatches, Influence, OffTheBall, Positioning, TeamWork, WorkRate, Acceleration, Agility, Balance, InjuryProneness, NaturalFitness, Pace, Stamina, Strength, Scrummaging, Hooking, Attacking, Defence, Kicking, KickingPower, GoalKicking, DropKicking, CrashBall, Passing, GapDefense, Tackling, Technique, Versatility, Rucking, Lineout, Communication, Handling, OneOnOnes, Discipline, Rating, LeftFoot, RightFoot) VALUES($personID, '$primaryPosition', $aggression, $anticipation, $bravery, $consistency, $creativity, $decisions, $dirtiness, $flair, $important, $influence, $offBall, $positioning, $teamwork, $workRate, $acceleration, $agility, $balance, $injury, $fitness, $pace, $stamina, $strength, $scrummaging, $hooking, $attacking, $defence, $kicking, $kickPower, $goalKick, $dropKick, $crashBall, $passing, $gapDef, $tackling, $technique, $versatility, $rucking, $rucking, $lineOut, $communication, $handling, $oneOnOne, $discipline, $rating, $leftFoot, $rightFoot)";

$result=mysqli_query($con,$query)
    or die ("Couldn't execute query 2" . mysqli_error($con));


I assume it is referring to my INSERT statement as it prints "Couldn't execute query 2". Sorry it's quite a big insert statement too rolleyes.gif

Thank you in advance
jono99
Okay, i sort of came right with this.. thanks guys

Another problem though, I have a form that generates the figures for this insert statement but it doesn't seem to be getting the numbers from the form as it is inserting zero's (0) into the table for those columns. Yet it manages to get two other columns fine and insert them.. :huh:

This is the part that works:
CODE
$firstName = $_POST['firstName'];
$surname = $_POST['surname'];
$person = $_POST['personType'];
$date = $_POST['birthDate'];
$city = $_POST['birthCity'];
$nation = $_POST['nation'];
$nationIcon = $_POST['nationComboBox'];
$position = $_POST['positionComboBox'];


And here is the part that doesn't:
CODE
$consistency = $_POST['consistency'];
$creativity = $_POST['creativity'];    //5    
$decisions = $_POST['decisions'];
$dirtiness = $_POST['dirtiness'];
$flair = $_POST['flair'];
$important = $_POST['important'];
$influence = $_POST['influence'];    //10
$offBall = $_POST['offBall'];


Which, to me, looks exactly the same...

QUOTE
<form action="insertDetails.php" method="post" name="playerForm">
<div style="position:absolute; width:401px; left: 250px; top: 15px;">
<table width="399">
<tr>
<td width="129">First Name:</td>
<td width="150"><input type="text" id="firstName" name="firstName" /></td>

</tr>
<tr>
<td>Surname:</td>
<td><input type="text" id="surname" name="surname" /></td>
</tr>
.....
</table>
</div>
<div style="position: absolute; left: 25px; top: 225px; width: 1000px;">
<table width="100%">
<tr>
<td width="10%">Acceleration:</td>
<td width="10%"><input type="text" id="acceleration" name="acceleration" disabled="disabled" size="12" /></td>
<td width="6%">Kicking:</td>
<td width="10%"><input type="text" id="kicking" disabled="disabled" size="12" /></td>
<td width="9%">Aggression:</td>
<td width="10%"><input type="text" id="aggression" disabled="disabled" size="12" /></td>
<td width="11%">Balance:</td>
<td width="10%"><input type="text" id="balance" disabled="disabled" size="12" /></td>
<td width="14%">Technique:</td>
<td width="10%"><input type="text" disabled="disabled" id="technique" size="12" /></td>
</tr>
.....
</table>
</div>
</form>
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2012 Invision Power Services, Inc.