I have this website I'm working on that matches up two objects and I found a pairing function to generate a unique id number for each matchup. That's all well and good, however I do not want to fill in the 7000 something unique numbers into a database. So, I thought of an idea. I was gonna use PHP and while loops to insert these values automatically. Unfortunately, I have run into quite the issue. This is the code I have so far:
<?php
$db = new PDO('mysql:host=hostname;dbname=db_name;charset=utf8', 'username', 'pasword');
$x = 2;
$y = 1;
while ($x <= 117) {
$num = ((pow($x,2) + (3*$x) + (2 * $x * $y) + $y + pow($y,2))/2);
echo $num ."<br>";
$sql = "INSERT INTO votes (match) VALUES (:match)";
$q = $db->prepare($sql);
$q->execute(array(':match'=>$num));
$x = $x + 1;
}
?>
and when I try to run this I get
Fatal error:
Uncaught exception 'PDOException' with message 'SQLSTATE[42000]:
Syntax error or access violation: 1064 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 'match) VALUES (?)' at line 1' in
/home/content/70/11524070/html/matchup/math.php:11 Stack trace: #0
/home/content/70/11524070/html/matchup/math.php(11):
PDO->prepare('INSERT INTO vot...') #1 {main} thrown in
/home/content/70/11524070/html/matchup/math.php on line 11
any ideas as to how to get this to work?