Lamez Posted March 16, 2009 Share Posted March 16, 2009 I keep getting a mySql error, but I have no idea why, can someone help me look for the error? This is the 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 '1, 2, 3, 4, 5, 6, 7, VALUES ('Lamez', 'a', 'Louisville', 'Ohio St.', 'Utah', ' at line 1 <?php mysql_query("INSERT INTO `basket_rnd1` (user, region, 1, 2, 3, 4, 5, 6, 7, VALUES ('".$user_."', '".$x."', '".$a."', '".$b."', '".$c."', '".$d."', '".$e."', '".$f."', '".$g."', '".$h."')") or die(mysql_error()); ?> Whole Code: <?php ob_start(); $path = "../../"; $title = "Basketball Bracket"; $rank = "yes"; $u_login = "yes"; include ($path."main/include/cons/head.php"); $y = $_SESSION['xz']; $end = "endRnd_on"; $end2 = "endRnd_on2"; $end3 = "endRnd_on3"; $end4 = "endRnd_on4"; if($y == $end || $y == $end2 || $y == $end3 || $y == $end4){ if($y == $end){ $region = 1; $x = "a"; $re = "b"; } else if($y == $end2){ $region = 2; $x = "b"; $re = "c"; }else if($y == $end3){ $region = 3; $x = "c"; $re = "d"; }else if($y == $end4){ $region = 4; $x = "d"; $re = "e"; }else{ header("Location: ?yyz=r112d"); } $a = $_POST['1']; $b = $_POST['2']; $c = $_POST['3']; $d = $_POST['4']; $e = $_POST['5']; $f = $_POST['6']; $g = $_POST['7']; $h = $_POST['8']; $i = $_POST['9']; $j = $_POST['10']; $k = $_POST['11']; $l = $_POST['12']; $m = $_POST['13']; $n = $_POST['14']; $o = $_POST['15']; mysql_query("INSERT INTO `basket_reg` (id, name) VALUES ('1','A')")or die(mysql_error()); mysql_query("INSERT INTO `basket_rnd1` (user, region, 1, 2, 3, 4, 5, 6, 7, VALUES ('".$user_."', '".$x."', '".$a."', '".$b."', '".$c."', '".$d."', '".$e."', '".$f."', '".$g."', '".$h."')") or die(mysql_error()); mysql_query("INSERT INTO `basket_rnd2` (user, region, 9, 10, 11, 12) VALUES ('".$user_."', '".$x."', '".$i."', '".$j."', '".$k."', '".$l."')") or die(mysql_error()); mysql_query("INSERT INTO `basket_rnd3` (user, region, 13, 14) VALUES ('".$user_."', '".$x."', '".$m."', '".$n."')") or die(mysql_error()); mysql_query("INSERT INTO `basket_rnd4` (user, region, 15) VALUES ('".$user_."', '".$x."', '".$o."')") or die(mysql_error()); header("Location index.php?region=".$re); }else{ echo "ERROR!"; } ?> <?php include ($path."main/include/cons/foot.php"); ?> Any Ideas? Thanks Guys Quote Link to comment https://forums.phpfreaks.com/topic/149712-solved-need-fresh-eyes-error/ Share on other sites More sharing options...
PFMaBiSmAd Posted March 16, 2009 Share Posted March 16, 2009 A) Don't use numbers as column names, and B) If you do use numbers as column names you must enclose them in back-ticks ` so that they are treated as identifiers rather than as numeric data. Quote Link to comment https://forums.phpfreaks.com/topic/149712-solved-need-fresh-eyes-error/#findComment-786137 Share on other sites More sharing options...
Maq Posted March 16, 2009 Share Posted March 16, 2009 I think it's a a problem with the value of $d, are there any special character or anything? You don't have to break in and out of PHP it will interpolate with just: ('$user_', '$x', etc... You should also be using mysq_real_escape_string() on all your values. Quote Link to comment https://forums.phpfreaks.com/topic/149712-solved-need-fresh-eyes-error/#findComment-786138 Share on other sites More sharing options...
Lamez Posted March 16, 2009 Author Share Posted March 16, 2009 so like: <?php mysql_query("INSERT INTO `basket_rnd1` (user, region, `1`, `2`, `3`, `4`, `5`, `6`, `7`, `8`) [..] "); ?> Quote Link to comment https://forums.phpfreaks.com/topic/149712-solved-need-fresh-eyes-error/#findComment-786139 Share on other sites More sharing options...
Lamez Posted March 16, 2009 Author Share Posted March 16, 2009 w00t, that worked, but now why does it not redirect? oh forgot the : Quote Link to comment https://forums.phpfreaks.com/topic/149712-solved-need-fresh-eyes-error/#findComment-786141 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.