maestrog Posted August 27, 2008 Share Posted August 27, 2008 I have echoed all the field names to make sure they show properly. Let me know if you would like more..I only included this part of switch. I am trying to write nfl picks to database.Thanks for help. 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 = REDSKINS WHERE id = '1' LIMIT 1' at line 1 <?php case "do_update": $p_name = $_POST['p_name']; $player = "player"; $entry = "INSERT INTO $player (name) VALUES ('$p_name')"; if ($_POST['p_name']) { $result = mysql_query($entry, $link) or die (mysql_error()); } $pick = $_POST["yo$w$j"]; $query2="SELECT * FROM $player WHERE name ='$p_name'"; $pid = mysql_query($query2, $link) or die (mysql_error()); $look = mysql_fetch_array($pid, MYSQL_ASSOC); $myid = $look[id]; /*$entered = "UPDATE $player SET gm1 1 = 'Giants' WHERE id ='10' LIMIT 1" ; $entered = "UPDATE $player SET gm1 1 = $pick WHERE id = '$myid'";//$p_name $result = mysql_query($entered, $link) or die (mysql_error());*/ for ($w = 1; $w < 18; ++$w){ $p_name = $_POST['p_name']; $weekly = "week_$w"; echo "<html><head><title>Update scores</title><meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>" ."<LINK media=screen href='includes/format.css' type=text/css rel=stylesheet></head><body>" ."<table width='646' border='1'><tr><td colspan='6' class=killer>Update Weekly Scores for $weekly for $p_name</td></tr>"; $query1="SELECT * FROM $weekly"; $result = mysql_query($query1, $link); $num=mysql_num_rows($result); $numb = $num + 1; for ($j = 1; $j < $numb; ++$j) { $enter = "gm$w $j"; $player = "player"; $pick = $_POST["yo$w$j"]; $entered = "UPDATE $player SET $enter = $pick WHERE id = '$myid' LIMIT 1";//help me..i am causing errors here! $result = mysql_query($entered, $link) or die (mysql_error()); $game = mysql_fetch_array($result, MYSQL_ASSOC) or die (mysql_error()); $id = $game[id]; echo "<html><head><LINK media=screen href='includes/format.css' type=text/css rel=stylesheet></head><body><table width='350'border='1'>" ."<tr><td class=nice height='20'width='94'>$pick</td><td class=nice width='40'>$enter</td>" ."<td class=nice width='94'></td><td class=nice width='40'></td></tr>" ."</table></body></html>"; } } break; } ?> Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted August 27, 2008 Share Posted August 27, 2008 String values need to be enclosed in single-quotes so that they are treated as strings and not identifiers or keywords. Quote Link to comment Share on other sites More sharing options...
fenway Posted August 27, 2008 Share Posted August 27, 2008 Not only that, but your column name has a space in it???? Quote Link to comment Share on other sites More sharing options...
maestrog Posted August 27, 2008 Author Share Posted August 27, 2008 Thanx, but no help yet. The space was so that variable would show up. Variables cannot start with an integer so I put gm first. Then $w$j would not show up unless I put something in the middle. I am looping through weekly picks with the $w and 16 game picks with the $j. I read in an mysql site that spaces are ok. I also know about the quotes. I tried quoting everything and anything. I am sure that the problem is in the game pick variable which is seen as an integer or something. I'm tellin ya, I'm ready for major drugs here. Should I attach the whole folder of files? Any more ideas are appreciated. Quote Link to comment Share on other sites More sharing options...
fenway Posted August 27, 2008 Share Posted August 27, 2008 Thanx, but no help yet. The space was so that variable would show up. Huh? I'm talking about: /*$entered = "UPDATE $player SET gm1 1 = 'Giants' WHERE id ='10' LIMIT 1" ; $entered = "UPDATE $player SET gm1 1 = $pick WHERE id = '$myid'";//$p_name $result = mysql_query($entered, $link) or die (mysql_error());*/ [code] [/code] Quote Link to comment Share on other sites More sharing options...
maestrog Posted August 27, 2008 Author Share Posted August 27, 2008 That was a test...thats why it is commented out. I tried to update with manual values without the loop. It produced that same error. I now have gm$w-$j for the $enter value. I cannot even think of another way to do it. I usually work around problems, but this is a bugger. Quote Link to comment Share on other sites More sharing options...
fenway Posted August 27, 2008 Share Posted August 27, 2008 Yes, but the error message you posted is from the query in the commented code -- so what's the actual problem? Quote Link to comment Share on other sites More sharing options...
maestrog Posted August 28, 2008 Author Share Posted August 28, 2008 Thanks for the help. I fixed some sloppy code earlier in my script...earlier query with the same variable name. Who knows how to post the "solved" thing? Quote Link to comment Share on other sites More sharing options...
maestrog Posted August 28, 2008 Author Share Posted August 28, 2008 [solved] Quote Link to comment 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.