MySQL Forums
Forum List  »  PHP

UPDATE error
Posted by: Jeremiah Ramsey
Date: December 31, 2012 04:51PM

With this html document and PHP script, I have attempted to save information in a row that already exists by including UPDATE and WHERE to make sure the information goes into the right row. I am getting this response:


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 ' last_name=, email=, input1=, input2=, input3=, input4=, input5=, input6=, input' at line 1


This is my HTML document:


<!DOCTYPE html>
<html>
<head>
<title>English Assessment Test - 3J-Network</title>
<link href="/css/fastylesheet.css" rel="stylesheet" type="text/css" />
</head>


<body><table align="center"><tr><td width="610">
<img class="logo" src="/images/logo.jpg" />
<h1>English Assessment Test</h1>
<ul class="anchor">
<li class="anchor"><span class="roundtop"><a class="bar" href="index.html">Back to Homepage</a></span></li>
</ul>
<table><tr>
<td>
<p><form action="scripts/english_test2.php" method="POST">
<fieldset>
<p>So that your results will be saved, please fill in the user ID that we gave you.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>
<label for="user_id">Your user ID:</label>
<input type="text" name="user_id" size="20" /><br />
</fieldset>
<br />
<fieldset>
<h4>Level 2 Questions</h4>
<ol>
<li>
<p>Henry needs to go to work now. Choose the most appropriate sentence.</p>
<input type="radio" name="input11" value="1a" /><span>a) "I work."</span><br />
<input type="radio" name="input11" value="1b" /><span>b) "I go to work."</span><br />
<input type="radio" name="input11" value="1c" /><span>c) "I am working now."</span><br />
<input type="radio" name="input11" value="1d" /><span>d) "I have to go to work now."</span><br />
<input type="radio" name="input11" value="1e" /><span>e) none of the above</span><br />
</li>
<li>
<p>Caleb says, "I see a plate of cookies on the table. But since I am already fat, I will resist the temptation." What does he mean?</p>
<input type="radio" name="input12" value="2a" /><span>a) He will eat all of the cookies.</span><br />
<input type="radio" name="input12" value="2b" /><span>b) He will eat only one of the cookies.</span><br />
<input type="radio" name="input12" value="2c" /><span>c) He will not eat any cookies.</span><br />
<input type="radio" name="input12" value="2d" /><span>d) He will throw the cookies away.</span><br />
<input type="radio" name="input12" value="2e" /><span>e) none of the above</span><br />
</li>
<li>
<p>Chun-soo has stopped using Facebook. What does this mean?</p>
<input type="radio" name="input13" value="3a" /><span>a) Chun-soo never had a Facebook account.</span><br />
<input type="radio" name="input13" value="3b" /><span>b) Chun-soo will never use Facebook again.</span><br />
<input type="radio" name="input13" value="3c" /><span>c) Chun-soo will start using Facebook again.</span><br />
<input type="radio" name="input13" value="3d" /><span>d) Chun-soo used Facebook in the past, but is not using it anymore.</span><br />
<input type="radio" name="input13" value="3e" /><span>e) none of the above</span><br />
</li>
<li>
<p>Whether or not she wins the game, she will be happy. What does this mean?</p>
<input type="radio" name="input14" value="4a" /><span>a) She will be unhappy if she loses.</span><br />
<input type="radio" name="input14" value="4b" /><span>b) She will only be happy if she wins the game.</span><br />
<input type="radio" name="input14" value="4c" /><span>c) She will be happy in both situations.</span><br />
<input type="radio" name="input14" value="4d" /><span>d) She will be unhappy in both situations.</span><br />
<input type="radio" name="input14" value="4e" /><span>e) none of the above</span><br />
</li>
<li>
<p></p>
<input type="radio" name="input15" value="5a" /><span></span><br />
<input type="radio" name="input15" value="5b" /><span></span><br />
<input type="radio" name="input15" value="5c" /><span></span><br />
<input type="radio" name="input15" value="5d" /><span></span><br />
<input type="radio" name="input15" value="5e" /><span>e) none of the above</span><br />
</li>
<li>
<p>The little boy built a house out of blocks. That made his mother happy. How can one combine these two sentences?</p>
<input type="radio" name="input16" value="6a" /><span>a) The little boy built a house out of blocks, which made his mother happy.</span><br />
<input type="radio" name="input16" value="6b" /><span>b) The little boy built a house out of blocks, that made his mother happy.</span><br />
<input type="radio" name="input16" value="6c" /><span>c) The little boy built a house out of blocks, what made his mother happy.</span><br />
<input type="radio" name="input16" value="6d" /><span>d) The little boy built a house out of blocks. That made his mother happy.</span><br />
<input type="radio" name="input16" value="6e" /><span>e) none of the above</span><br />
</li>
<li>
<p>He cannot afford this computer unless he sells his motorcycle.</p>
<input type="radio" name="input17" value="7a" /><span>a) If he does not sell his motorcycle, he cannot afford the computer.</span><br />
<input type="radio" name="input17" value="7b" /><span>b) He will sell his motorcycle no matter what.</span><br />
<input type="radio" name="input17" value="7c" /><span>c) He will purchase the computer no matter what.</span><br />
<input type="radio" name="input17" value="7d" /><span>d) After purchasing the computer, he will buy a cheaper motorcycle.</span><br />
<input type="radio" name="input17" value="7e" /><span>e) none of the above</span><br />
</li>
<li>
<p>Patricia says, "I doubt you can learn to speak English fluently so quickly." What does she mean?</p>
<input type="radio" name="input18" value="8a" /><span>a) She thinks you can learn to speak English fluently very quickly.</span><br />
<input type="radio" name="input18" value="8b" /><span>b) She thinks you cannot learn to speak English.</span><br />
<input type="radio" name="input18" value="8c" /><span>c) She thinks it will take at least two years for you to learn to speak English fluently.</span><br />
<input type="radio" name="input18" value="8d" /><span>d) She thinks you can probably not learn to speak English fluently so quickly.</span><br />
<input type="radio" name="input18" value="8e" /><span>e) none of the above</span><br />
</li>
<li>
<p>"Robin may not want to play soccer today." What does this mean?</p>
<input type="radio" name="input19" value="9a" /><span>a) Robin will not play soccer today.</span><br />
<input type="radio" name="input19" value="9b" /><span>b) Robin will play soccer today.</span><br />
<input type="radio" name="input19" value="9c" /><span>c) Robin wants to play soccer today.</span><br />
<input type="radio" name="input19" value="9d" /><span>d) Robin is sick.</span><br />
<input type="radio" name="input19" value="9e" /><span>e) none of the above</span><br />
</li>
<li>
<p>Chun-soo asks Makoto, "Do you mind if I cook dinner tonight?" If Makoto wants Chun-soo to cook tonight, how should he respond?</p>
<input type="radio" name="input20" value="10a" /><span>a) Oh, yes.</span><br />
<input type="radio" name="input20" value="10b" /><span>b) Yes, I do.</span><br />
<input type="radio" name="input20" value="10c" /><span>c) No, please do.</span><br />
<input type="radio" name="input20" value="10d" /><span>d) No, please don't.</span><br />
<input type="radio" name="input20" value="10e" /><span>e) none of the above</span><br />
</li>
</ol>
</fieldset>
<br />
<fieldset>
<h4>Submit your answers</h4>
<input type="submit" value="Submit" />
</fieldset>
</form></p>
</td>
</tr></table>
</td></tr></table></body>
</html>



and this is my PHP script:


<?php

require '/homepages/9/d445176724/htdocs/firhavenacademy/scripts/app_config.php';
require '/homepages/9/d445176724/htdocs/firhavenacademy/scripts/database_connection.php';

$user_id = trim($_REQUEST['user_id']);
$first_name = trim($_REQUEST['first_name']);
$last_name = trim($_REQUEST['last_name']);
$email = trim($_REQUEST['email']);
$input1 = trim($_REQUEST['input1']);
$input2 = trim($_REQUEST['input2']);
$input3 = trim($_REQUEST['input3']);
$input4 = trim($_REQUEST['input4']);
$input5 = trim($_REQUEST['input5']);
$input6 = trim($_REQUEST['input6']);
$input7 = trim($_REQUEST['input7']);
$input8 = trim($_REQUEST['input8']);
$input9 = trim($_REQUEST['input9']);
$input10 = trim($_REQUEST['input10']);
$input11 = trim($_REQUEST['input11']);
$input12 = trim($_REQUEST['input12']);
$input13 = trim($_REQUEST['input13']);
$input14 = trim($_REQUEST['input14']);
$input15 = trim($_REQUEST['input15']);
$input16 = trim($_REQUEST['input16']);
$input17 = trim($_REQUEST['input17']);
$input18 = trim($_REQUEST['input18']);
$input19 = trim($_REQUEST['input19']);
$input20 = trim($_REQUEST['input20']);
$input21 = trim($_REQUEST['input21']);
$input22 = trim($_REQUEST['input22']);
$input23 = trim($_REQUEST['input23']);
$input24 = trim($_REQUEST['input24']);
$input25 = trim($_REQUEST['input25']);
$input26 = trim($_REQUEST['input26']);
$input27 = trim($_REQUEST['input27']);
$input28 = trim($_REQUEST['input28']);
$input29 = trim($_REQUEST['input29']);
$input30 = trim($_REQUEST['input30']);
$input31 = trim($_REQUEST['input31']);
$input32 = trim($_REQUEST['input32']);
$input33 = trim($_REQUEST['input33']);
$input34 = trim($_REQUEST['input34']);
$input35 = trim($_REQUEST['input35']);
$input36 = trim($_REQUEST['input36']);
$input37 = trim($_REQUEST['input37']);
$input38 = trim($_REQUEST['input38']);
$input39 = trim($_REQUEST['input39']);
$input40 = trim($_REQUEST['input40']);


$insert_sql = "UPDATE test_and_taker SET first_name=$first_name, last_name=$last_name, email=$email, input1=$input1, input2=$input2, input3=$input3, input4=$input4, input5=$input5, input6=$input6, input7=$input7, input8=$input8, input9=$input9, input10=$input10, input11=$input11, input12=$input12, input13=$input13, input14=$input14, input15=$input15, input16=$input16, input17=$input17, input18=$input18, input19=$input19, input20=$input20, input21=$input21, input22=$input22, input23=$input23, input24=$input24, input25=$input25, input26=$input26, input27=$input27, input28=$input28, input29=$input29, input30=$input30, input31=$input31, input32=$input32, input33=$input33, input34=$input34, input35=$input35, input36=$input36, input37=$input37, input38=$input38, input39=$input39, input40=$input40 WHERE user_id=$user_id;";

// Insert the user into the database
mysql_query($insert_sql)
or die(mysql_error());

?>


Does anyone see the problem?

Thanks in advance.

Options: ReplyQuote


Subject
Written By
Posted
UPDATE error
December 31, 2012 04:51PM
January 01, 2013 03:02AM
January 08, 2013 05:32PM
January 08, 2013 07:41PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.