Jump to content

[SOLVED] Syntax errors driving crazy


maestrog

Recommended Posts

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;
}
?>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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]

Link to comment
Share on other sites

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.

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.