frostyhorse Posted August 28, 2009 Share Posted August 28, 2009 For my project, I need to let members update multiple fields at once. There's a total of four fields that I want them to be able to update on their own free will. This is what I have started on: <? session_name('usersession'); session_start(); ?> <html> <head> <title>Equine Revolution's Equine Registry</title> <link rel="stylesheet" href="style.css" type="text/css"> </head> <body> <center> <table id="main"> <tr><td> <p><h1>Update A Horse</h1> <? if(!isset($peacock)) { include('menu2.php'); include('loginform.php'); exit(); } else { include('menu1.php'); echo ' <p> <form action="update2.php" method="post"> Horse Id: <input type="text" name="id" /><br> Horse Name: <input type="text" name="id" /><br> For Stud: <input type="text" name="stud" /> <br> <input type="submit" /> </form> </p>'; } ?> <p> <? include('foot.php'); ?> </p> </td></tr> <tr><td></td></tr> </table> </center> </body> </html> Right now they -should- be able to say yes, this stallion can breed or no, this stallion cannot breed. I know how to add in the other fields for breeding information, for sale or not, and sale information. This is what I have written for the update2.php page: <?php $con = mysql_connect("fdb2.awardspace.com","erregistry_db","carmengj99"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("erregistry_db"); $sql="UPDATE registry SET stud='$_POST['stud'], WHERE id='$_POST['id'], AND name='$_POST['name'],"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "Horse has been updated."; mysql_close($con) ?> <a href="update.php">Update Another Horse</a> Right now I get this error: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/www/erregistry.awardspace.us/update2.php on line 10 and not exactly sure what it is... =/ I first need help fixing the error and the writing it so the three other fields mentioned above can be updated, too. Quote Link to comment Share on other sites More sharing options...
lemmin Posted August 28, 2009 Share Posted August 28, 2009 You can't use array indices inside of double quotes like you can with regular variables. Also, you are missing the end single quotes for all of them and you have an extra comma at the end. Try it like this: $sql="UPDATE registry SET stud='".$_POST['stud']."', WHERE id='".$_POST['id']."', AND name='".$_POST['name']."'"; Quote Link to comment Share on other sites More sharing options...
frostyhorse Posted September 1, 2009 Author Share Posted September 1, 2009 I changed that and am no getting an error, "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 'WHERE id='Blue Falcon W', AND name=''' at line 2" I put in '3' for the ID, 'Blue Falcon W' for the name, and 'yes' for the stud, which I want to update. Quote Link to comment Share on other sites More sharing options...
frostyhorse Posted September 2, 2009 Author Share Posted September 2, 2009 anyone? Quote Link to comment Share on other sites More sharing options...
satya123 Posted September 2, 2009 Share Posted September 2, 2009 Hi frostyhorse, Use the following it will work. $sql="UPDATE registry SET stud='$_POST[stud]' WHERE id='$_POST[id]' AND name='$_POST[name]' "; There is no need to put ',' .When we update multiple column at a time then we put ',' between the diffrent column name. 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.