Hello;
I am confused by the error message I am getting when I try to run the insert script. The error message I am geting is:
Error, SELECT query failed - Unknown column 'airplanes' in 'where clause'
I dont understand why that is coming up. In my form, the topic I put in was 'airplanes', however, I dont see why it is saying that in the error message. Here is the code for the script that is not working:
<?php
session_start();
include "db_config.php";
mysql_select_db(iceregen_MStudio);
if ($_SESSION['Valid'] <> true)
{
header("Location: MStudioMain.php");
}
$thread1=$_POST['threadtopic'];
$message1=$_POST['threadmessage'];
$USID=$_SESSION['Unumber'];
$forum1=$_SESSION['forum'];
$forum2=$_SESSION['PassForum'];
$today = date("Y-m-d");
echo '<table width="100" border="2" cellspacing="0" cellpadding="0" bordercolor="#800040">';
echo '<tr>';
echo ' <td><font face="Arial" color="#FFFF00">Forum Name</td>';
echo ' <td><font face="Arial" color="#FFFF00">' . $forum2 . '</td>';
echo '</tr>';
echo '<tr>';
echo ' <td><font face="Arial" color="#FFFF00">Thread</td>';
echo ' <td><font face="Arial" color="#FFFF00">' . $thread1. '</td>';
echo '</tr>';
echo '<tr>';
echo ' <td><font face="Arial" color="#FFFF00">UserName</td>';
echo ' <td><font face="Arial" color="#FFFF00">' . $USID. '</td>';
echo '</tr>';
echo '<tr>';
echo ' <td><font face="Arial" color="#FFFF00">Date</td>';
echo ' <td><font face="Arial" color="#FFFF00">' . $today. '</td>';
echo '</tr>';
echo '<tr>';
echo ' <td><font face="Arial" color="#FFFF00">Content</td>';
echo ' <td><font face="Arial" color="#FFFF00">' . $message1 . '</td>';
echo '</tr>';
echo '</table>';
$querythread = "INSERT INTO `threads` (`ThreadID`, `ForumID`, `UserID`, `name`) VALUES ('', '$forum2', '$USID', '$thread1')";
$resultthread = mysql_query($querythread) or die('Error, insert query failed - '.mysql_error());
$querythreadID = "SELECT ThreadID, ForumID, UserID, name FROM threads WHERE name = $thread1";
$resultthreadID = mysql_query($querythreadID) or die('Error, SELECT query failed - '.mysql_error());
while($row5 = mysql_fetch_array($resultthreadID, MYSQL_ASSOC))
{
$ThreadNumber = $row5['ThreadID'];
}
echo $ThreadNumber;
$querypost = "INSERT INTO posts (PostID, date_time, ThreadID, ForumID, UserID, text) VALUES ('', '$today', '$ThreadNumber', '$forum2', '$USID', '$message1');
mysql_query($querypost) or die('Error, insert query failed - '.mysql_error());
mysql_close();
?>
I am echoing out the results of the form into a table so that the user can see what they entered was what was posted. But thats not where the problem is. The error refers to the segment :
$querythreadID = "SELECT ThreadID, ForumID, UserID, name FROM threads WHERE name = $thread1";
Somehow its telling me there is no column named after the string input , but the column I am looking at is called 'name', and I have verified that my first insert statement works, and the $thread1 is inserted correctly into the column 'name' as a string, which is what it is set up for.
Can anyone see what I am doing wrong?
Thanks;
Ice