Jay2391 Posted January 31, 2007 Share Posted January 31, 2007 I cut off lot of the code fo simplicity but the main goal is to update an existing table in whish i will update multiple fields at a one time with a post submition...I get this error..Cannot Update TableYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SET win='', loss='', tie='', rank='', eliminated='', fi' at line 1[code] print "<form action=\"Slef" method=\"post\">"; print 'W: <input type="text" name="win_update" size"20" value="' . $_POST['win_update'] . '"/><br />'; print 'L: <input type="text" name="loss_update" size"10" value="' . $_POST['loss_update'] . '"/><br />'; print '<br><input type="submit" name="submit" size"20" value="Update Records"/><br /></h4>'; $win_update = $_POST['win_update']; $loss_update = $_POST['loss_update']; $user_update = "UPDATE $tabletr SET win='$win_update', loss='$loss_update' WHERE user_name='$chg_player'"; mysql_query($user_update) or die ("Cannot Update Table". mysql_error()); ?>[/code] Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted January 31, 2007 Share Posted January 31, 2007 What value does "$tabletr" have? Quote Link to comment Share on other sites More sharing options...
marcus Posted January 31, 2007 Share Posted January 31, 2007 [code=php:0]$sql = "UPDATE `$tablename` SET `win` ='$win_update', `loss` ='$loss_update' WHERE `user_name` ='$username'";$res = mysql_query($sql) or die(mysql_error());[/code] Quote Link to comment Share on other sites More sharing options...
Jay2391 Posted January 31, 2007 Author Share Posted January 31, 2007 same error...and $tabletr is a variable with the table name Quote Link to comment Share on other sites More sharing options...
marcus Posted January 31, 2007 Share Posted January 31, 2007 Replace the variable of the table name with the actual table name in your query. Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted January 31, 2007 Share Posted January 31, 2007 I understand that it holds the table name...but what exactly is the tables name?Why not just replace it with the actual name? Quote Link to comment Share on other sites More sharing options...
Jay2391 Posted January 31, 2007 Author Share Posted January 31, 2007 I like to use the include();and i save my table names and my functions thereanyway i figure out what as wrong $chg_player variable was not carring over ... thanks anyway 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.