Solar Posted December 1, 2010 Share Posted December 1, 2010 SQL PHP UPDATE: $sql="UPDATE blog (name, title, entry, na, ip) SET ('$_POST[name]','$_POST[title]','$_POST[entry]','$_POST[na]','$_POST[ip]')"; I need the SQL to read the users name to detect that the edit is there own blog post. SQL PHP PAGE: $sql = "SELECT id, name, title, entry, na, ip FROM blog WHERE name = '" . $_SESSION['username'] . "' AND `id` = '" . htmlspecialchars($_GET["id"]) . "'"; ALSO <form action="profile_blogs_edit.php" method="post"> THE ERROR I AM GETTING: 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 '(title, entry, na, entry, ip) SET id='', name='Steven', 'Macromedia', ' Remem' at line 1 So is there a way to make this?: $sql="UPDATE blog (name, title, entry, na, ip) SET ('$_POST[name]','$_POST[title]','$_POST[entry]','$_POST[na]','$_POST[ip]') WHERE name = '" . $_SESSION['username'] . "'"; Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/220369-update-sql/ Share on other sites More sharing options...
PFMaBiSmAd Posted December 1, 2010 Share Posted December 1, 2010 The following is the syntax definition for an UPDATE query, with the commonly used parts in bold - UPDATE [LOW_PRIORITY] [iGNORE] table_reference SET col_name1={expr1|DEFAULT} [, col_name2={expr2|DEFAULT}] ... [WHERE where_condition] [ORDER BY ...] [LIMIT row_count] Typical usage would be - UPDATE your_table SET your_column1 = 'some value', your_column2 = 'some value' WHERE your_where_condition_goes_here Quote Link to comment https://forums.phpfreaks.com/topic/220369-update-sql/#findComment-1141874 Share on other sites More sharing options...
Solar Posted December 1, 2010 Author Share Posted December 1, 2010 Thanks! I just just figured this out. My SQL Statement $sql="UPDATE blog SET name='$_POST[name]', title='$_POST[title]', entry='$_POST[entry]', na='$_POST[na]', ip='$_POST[ip]' WHERE name = '" . $_SESSION['username'] . "'"; Quote Link to comment https://forums.phpfreaks.com/topic/220369-update-sql/#findComment-1141875 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.