Jump to content

Update SQL


Solar

Recommended Posts

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!

Link to comment
https://forums.phpfreaks.com/topic/220369-update-sql/
Share on other sites

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

 

 

Link to comment
https://forums.phpfreaks.com/topic/220369-update-sql/#findComment-1141874
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.