This is my mysql statement but for some reason it isn’t actually working and I can’t figure out why. Thanks in advance!
$ID = $_GET['post'];
$length = $_POST['excerpt_length'];
more code here to connect and select db...
mysql_query("
INSERT INTO wp_posts (excerpt)
VALUES(" . $length . ")
WHERE ID = " . $ID . "
OR post_name LIKE '" . $ID . "%'");
This is for wordpress and I’m making an option to add an excerpt length because as far as I am aware, there isn’t any yet. Thanks!
Ethan Brouwer
If you already have an ID, and you want to keep the ID as it is, use an
UPDATE
statement.You cant use where in insert into because you are supposed to create a new record, there is no referenced to look for. You must use Update instead.
INSERT ...
inserts a new row into the table. It has noWHERE
clause.If you want to update an existing row, use an
UPDATE ...
statement.As Dan points out your syntax is incorrect. If you want to limit the excerpt length in WordPress you can use filters. Have a look at this post.
I haven’t checked, but I wouldn’t think you can use an OR-statement in an INSERT-query. Maybe do another query before this one to find out an id to insert to..?