if (isset($_POST['submit'])) {
$date = date("l, M, d");
$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 (tid,topic,uname,body,forum_id,topic_id,date) VALUES ('$newid','$topic','$name','$body','$fid','1','$date')";
mysql_query($sql,$con) or die(mysql_error());
mysql_close();
echo $sql;
}
Ok, this is my code, here is what is happening. Whenever their is 1 or more rows in the table threads everything works just fine. However, if their are 0 rows in the table then it just goes to a white blank screen. Will not echo sql or anything that i try to tell it to do. But when their is 1 or more rows already in the table it all works fine.
Any ideas? Thank you
Anthony
P.S This is just the insert of a new thread in my mini forums for my site.