Jump to content

[SOLVED] yet another mysql question


TimUSA

Recommended Posts

when i use this code:

// CONFIGURATION SECTION
$times = $_POST['boats'];
$x = 0;

if ($_POST['points'][$x] == "DNF")
$points = ($_POST['boats'] +1) * $_POST['factor'];

else if ($_POST['points'][$x] == "DNS")
$points = ($_POST['boats'] +1) * $_POST['factor'];

else
$points = $_POST['points'][$x] * $_POST['factor'];
///POST TO DATABASE
if (isset($_POST['submitted'])) {
if ($_POST['factor'] == "3")
while ($x < $times) {
mysql_query("INSERT INTO ladder_points (memberName, date, factor, racePoints, matchPoints) VALUES ('$_POST['name'][$x]','$_POST['date']','$_POST['factor']','$_POST['points'][$x]','$points')");
$x++;
}
else {
while ($x < $times) {
mysql_query("INSERT INTO ladder_points (memberName, date, factor, racePoints, fleetPoints) VALUES ('$_POST['name'][$x]','$_POST['date']','$_POST['factor']','$_POST['points'][$x]','$points')");
$x++;
}
}

 

i get this error:

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/vskayc/public_html/Sources/Load.php(1773) : eval()'d code(209) : eval()'d code on line 17
Link to comment
Share on other sites

You probably just need back ticks around the field names, as I believe date would definitely be a reserved MySQL keyword.

 

<?php
mysql_query("INSERT INTO `ladder_points`
             (`memberName`, `date`, `factor`, `racePoints`, `matchPoints`)
              VALUES
             ('{$_POST['name'][$x]}','$_POST['date']','$_POST['factor']','{$_POST['points'][$x]}','$points')
             ");

 

PhREEEk

Link to comment
Share on other sites

yes sorry....i had actually made the column name 'raceDate' and was just a typo:

my code now looks like this:

// CONFIGURATION SECTION
$times = $_POST['boats'];
$x = 0;

if ($_POST['points'][$x] == "DNF")
$points = ($_POST['boats'] +1) * $_POST['factor'];

else if ($_POST['points'][$x] == "DNS")
$points = ($_POST['boats'] +1) * $_POST['factor'];

else
$points = $_POST['points'][$x] * $_POST['factor'];
///POST TO DATABASE
if (isset($_POST['submitted'])) {
if ($_POST['factor'] == "3") {
while ($x < $times) {
mysql_query("INSERT INTO `ladder_points`
             (`memberName`, `raceDate`, `factor`, `racePoints`, `matchPoints`)
              VALUES
             ('{$_POST['name'][$x]}','$_POST['date']','$_POST['factor']','{$_POST['points'][$x]}','$points')
             ");
$x++;
}
} else {
while ($x < $times) {
mysql_query("INSERT INTO `ladder_points`
             (`memberName`, `raceDate`, `factor`, `racePoints`, `matchPoints`)
              VALUES
             ('{$_POST['name'][$x]}','$_POST['date']','$_POST['factor']','{$_POST['points'][$x]}','$points')
             ");
$x++;
}
}
}

 

and I am getting this:

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/vskayc/public_html/Sources/Load.php(1773) : eval()'d code(209) : eval()'d code on line 20

 

sorry again...i didnt think this was a double post?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.