TimUSA Posted December 30, 2007 Share Posted December 30, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/83766-solved-yet-another-mysql-question/ Share on other sites More sharing options...
revraz Posted December 30, 2007 Share Posted December 30, 2007 And line 17 is? Quote Link to comment https://forums.phpfreaks.com/topic/83766-solved-yet-another-mysql-question/#findComment-426197 Share on other sites More sharing options...
TimUSA Posted December 30, 2007 Author Share Posted December 30, 2007 mysql_query("INSERT INTO ladder_points (memberName, date, factor, racePoints, matchPoints) VALUES ('$_POST['name'][$x]','$_POST['date']','$_POST['factor']','$_POST['points'][$x]','$points')"); Quote Link to comment https://forums.phpfreaks.com/topic/83766-solved-yet-another-mysql-question/#findComment-426198 Share on other sites More sharing options...
TimUSA Posted December 30, 2007 Author Share Posted December 30, 2007 this is probably in the wrong section, can you please move to the mysql board? Quote Link to comment https://forums.phpfreaks.com/topic/83766-solved-yet-another-mysql-question/#findComment-426213 Share on other sites More sharing options...
PHP_PhREEEk Posted December 30, 2007 Share Posted December 30, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/83766-solved-yet-another-mysql-question/#findComment-426226 Share on other sites More sharing options...
revraz Posted December 30, 2007 Share Posted December 30, 2007 Which we already told him in his other thread http://www.phpfreaks.com/forums/index.php/topic,174889.0.html Quote Link to comment https://forums.phpfreaks.com/topic/83766-solved-yet-another-mysql-question/#findComment-426228 Share on other sites More sharing options...
TimUSA Posted December 30, 2007 Author Share Posted December 30, 2007 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? Quote Link to comment https://forums.phpfreaks.com/topic/83766-solved-yet-another-mysql-question/#findComment-426234 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.