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] Link to comment https://forums.phpfreaks.com/topic/36412-submit-update-to-sql-db/ Share on other sites More sharing options...
pocobueno1388 Posted January 31, 2007 Share Posted January 31, 2007 What value does "$tabletr" have? Link to comment https://forums.phpfreaks.com/topic/36412-submit-update-to-sql-db/#findComment-173225 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] Link to comment https://forums.phpfreaks.com/topic/36412-submit-update-to-sql-db/#findComment-173226 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 Link to comment https://forums.phpfreaks.com/topic/36412-submit-update-to-sql-db/#findComment-173235 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. Link to comment https://forums.phpfreaks.com/topic/36412-submit-update-to-sql-db/#findComment-173280 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? Link to comment https://forums.phpfreaks.com/topic/36412-submit-update-to-sql-db/#findComment-173299 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 Link to comment https://forums.phpfreaks.com/topic/36412-submit-update-to-sql-db/#findComment-173305 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.