The code is as follows
Code: Select all
<?php
if (isset($_POST['submit'])) {
$con = mysql_connect("localhost","pinehead","") or die(mysql_error());
$db = mysql_select_db("lkcforum",$con) or die(mysql_error());
$sql = "SELECT tid FROM threads ORDER by tid DESC";
$result = mysql_query($sql,$con) or die(mysql_error());
$row = mysql_fetch_array($result) or die(mysql_error());
if (!isset($row['tid'])) { $last_id = $row['id']; } else { $last_id == "0"; }
$newid = $last_id + 1;
$sql = "INSERT INTO threads (topic,uname,body,forum_id,topic_id) VALUES
('$topic','$name','$body','$fid','1')";
mysql_query($sql,$con) or die(mysql_error());
mysql_close();
echo $sql;
$sql = "SELECT tid FROM threads WHERE
}
?>