//create and issue the first query
$add_topic_sql = "INSERT INTO forum_topics (topic_title, topic_create_time, topic_owner) VALUES ('$_POST[topic_title]',now(),'$_POST[topic_owner]')";
$add_topic_res = mysql_query($conn, $add_topic_sql)
or die(mysql_error($conn));
//get the id of the last query
$topic_id = mysql_insert_id($mysql);
Millsy013
0
Newbie Poster
Recommended Answers
Jump to PostWhat is the problem?
One thing that you could do to make the code better is instead of using the POST array in the actual query, you could clean it up and store it in another variable first, something like:
$topic_owner = mysqli_real_escape_string($conn, trim($_POST['topic_owner']));
All 4 Replies
phouse512
0
Junior Poster in Training
network18
15
Practically a Master Poster
Hummdis
5
Light Poster
network18
15
Practically a Master Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.