$query = "INSERT INTO `posts` (title, author, body, tags)
VALUES (`$title`, `$author`, `$body`, `$tags`)
(SELECT * FROM category WHERE name = $category)";
posts and category both are different tables?
$query = "INSERT INTO `posts` (title, author, body, tags)
VALUES (`$title`, `$author`, `$body`, `$tags`)
(SELECT * FROM category WHERE name = $category)";
posts and category both are different tables?
If you have variables with the values:
$etitle = somehow_escape($title); ...
INSERT INTO posts
(title, author, body, tags)
VALUES
('$etitle', '$eauthor', '$ebody', '$etags');
If fetching the values from another table:
INSERT INTO posts
(title, author, body, tags)
SELECT title, author, body, tags
FROM category
WHERE ...
'
were in the $title!SELECT
with INSERT
, there is no VALUES
cause.SELECT
subquery (in this situation).