William William - 2 years ago 109
PHP Question

Mysql query insert

I am trying to run this insert on a post page but it only inserts one table query which is discussion_topics table not both.

$sql = "INSERT INTO `discussion_topics`(`topic_title`,`topic_poster`,`topic_time`,`discussion_id`)";
$sql .= "VALUES('{$topic_title}','{$user_id}','{$discussion_time}','{$discussions}')";

$result = query ($sql);

$sql2 = "INSERT INTO `discussion_posts`(`discussion_id`,`poster_id`,`post_text`,`post_time`)";
$sql2 .= "VALUES('{$discussions}','{$user_id}','{$post_text}','{$discussion_time}')";
$result = query ($sql2);

Answer Source

after your query it should have this after both.

$result = query($sql);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download