php update query syntax check

please see attached snippet.
if I run the update statement replacing variable names with values in phpmyadmin, the update is successful.

when  i run this php (through flash form) it shows the success message but update doesn't actually occur.

I'm not getting any syntax errors running this through the browser either and the update works.

http://127.0.0.1/employeeSoccer/admin/editGame.php?newGameName=bob&newStartDate=2010-06-01&newEndDate=2010-06-31&newTurnsPerDay=3&newActiveState=0&newNumAttempts=4&editGameID=73 

i've checked the values being sent from flash and they're correct.
i've tried various configurations of strings, not strings.





$newGameName = $_REQUEST['newGameName'];
        $newStartDate = $_REQUEST['newStartDate'];
		$newEndDate = $_REQUEST['newEndDate'];
		$newTurnsPerDay = $_REQUEST['newTurnsPerDay'];
		$newActiveState = $_REQUEST['newActiveState'];
		$newNumAttempts = $_REQUEST['newNumAttempts'];
		$editGameID = $_REQUEST['editGameID'];
		
	    $result = mysql_query("UPDATE gamedetails SET gameName = '".$newGameName."', startDate = '".$newStartDate."', endDate = '".$newEndDate."', turnsPerDay = '".$newTurnsPerDay."', numAttempts = '".$newNumAttempts."', isActive = '".$newActiveState."' WHERE gameID = '$editGameID='");

               echo '<?xml version="1.0"?>';
               echo '<dataxml>';
               if ($result){
			  	 	echo '<row type="success">';
            		 echo '<result>success</result>';  
					 echo '</row>';
                } else {
					echo '<row type="error">';
                    echo '<error>no results</error>';  
					echo '</row>';
                }
                echo '</dataxml>';

Open in new window

LVL 39
blue-genieAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

john-formbyCommented:
Hi,

Please try the following code.

Hope this helps,

John
<?php
		$newGameName = $_REQUEST['newGameName'];
        $newStartDate = $_REQUEST['newStartDate'];
		$newEndDate = $_REQUEST['newEndDate'];
		$newTurnsPerDay = $_REQUEST['newTurnsPerDay'];
		$newActiveState = $_REQUEST['newActiveState'];
		$newNumAttempts = $_REQUEST['newNumAttempts'];
		$editGameID = $_REQUEST['editGameID'];
		
	    $result = mysql_query("UPDATE gamedetails SET gameName = '$newGameName', startDate = '$newStartDate', endDate = '$newEndDate', turnsPerDay = '$newTurnsPerDay', numAttempts = '$newNumAttempts', isActive = '$newActiveState' WHERE gameID = '$editGameID'") or die(mysql_error());

               echo '<?xml version="1.0"?>';
               echo '<dataxml>';
               if ($result){
			  	 	echo '<row type="success">';
            		 echo '<result>success</result>';  
					 echo '</row>';
                } else {
					echo '<row type="error">';
                    echo '<error>no results</error>';  
					echo '</row>';
                }
                echo '</dataxml>';
?>

Open in new window

0
hieloCommented:
>>but update doesn't actually occur.
That's probably because the gameID is not matching your where clause. You have:
WHERE gameID = '$editGameID='

Notice that trailing equal sign? Get rid of it:
WHERE gameID = '$editGameID'
0
kumaranmcaCommented:
Hi blue-genie,

I found some issues in your code...

DB connection property not in your code...and i made some changes...Kindly try the below code...
<?php
$conn=mysql_connect('localhost','******','*************');
$select_db=mysql_select_db('db_name',$conn);

			$newGameName = $_REQUEST['newGameName'];
			$newStartDate = $_REQUEST['newStartDate'];
			$newEndDate = $_REQUEST['newEndDate'];
			$newTurnsPerDay = $_REQUEST['newTurnsPerDay'];
			$newActiveState = $_REQUEST['newActiveState'];
			$newNumAttempts = $_REQUEST['newNumAttempts'];
			$editGameID = $_REQUEST['editGameID'];
                
            $result = mysql_query("UPDATE gamedetails SET 
			gameName = '".$newGameName."', 
			startDate = '".$newStartDate."', 
			endDate = '".$newEndDate."', 
			turnsPerDay = '".$newTurnsPerDay."', 
			numAttempts = '".$newNumAttempts."', 
			isActive = '".$newActiveState."' WHERE gameID = '".$editGameID."'");

               echo '<?xml version="1.0"?>';
               echo '<dataxml>';
               if ($result){
                                        echo '<row type="success">';
                         echo '<result>success</result>';  
                                         echo '</row>';
                } else {
                                        echo '<row type="error">';
                    echo '<error>no results</error>';  
                                        echo '</row>';
                }
                echo '</dataxml>';
?>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
blue-genieAuthor Commented:

@kumaranmca connection happens with includes not included in snippet.

@hielo - hi I saw that trailing "=" after I posted and have removed that but indirectly you're right. I was outputting in flash correctly so didn't put 2 and 2 together, but in the php i'd changed the variable to editGameID put was passing it in flash as gameID (forgot to change it there)


0
blue-genieAuthor Commented:
thanks all.
John the or die bit throws an error on your snippet. is that best practice to put the die in there?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.