0
を実行していない私は、PHPコードは次のページがあります。PHPクエリ
<?php
include ('databaseconnect1.php');
$sql1= "SELECT Categoryid, Categoryname, Categorydescription
FROM Categories";
$result1 = mysqli_query($db,$sql1);
if (!$result1){
echo "<font color = 'Green' .<p> No Category Found, Contact the
administrator </p> </font>";
}
function getPosts()
{
$posts = array();
$posts[0] = $_POST['topic_subject'];
$posts[1] = $_POST['date'];
$posts[2] = $_POST['topic_category'];
$posts[3] = $_SESSION['userid'];
return $posts;
}
if (isset($_POST['createtopicbutton']))
{
$data = getPosts();
$sql2 = "INSERT INTO Topics(Topic_subject, Topic_date,
Topic_category, Topic_by)
VALUES('$data[0]','$data[1]', '$data[2]', '$data[3]')";
$result2 = mysqli_query($db,$sql2);
if ($result2){
echo "<font color = 'Green' .<p> Topic Successfully Created </p>
</font>";
}else{
echo "<font color = 'Green' .<p> Topic NOT! Successfully Created </p>
</font>"; //This is the result I am getting specifically
}
}
?>
を、これは、同じページ上のHTMLコードです:
<form method = "post" action = "" >
<table cellspacing="15">
<tr>
<th>Subject </th>
<td><input type = "text" name = "topic_subject" /> </td>
</tr>
<tr>
<th>Category </th>
<?php echo '<td> <select name="topic_category"> ';
while($row = mysqli_fetch_assoc($result1))
{
echo '<option value="' . $row['Categoryid'] . '">' .
$row['Categoryname'] . '</option>';
}
echo '</select></td>';
?>
</tr>
<tr>
<th>Current Date </th>
<td><input type = "text" name = "date" /> </td>
</tr>
<tr>
<th> </th>
<td> <input type = "submit" value = "Create Topic!" name =
"createtopicbutton" /> </td>
</tr>
</table>
</form>
私は助けを必要と特定の部分"createtopicbutton"が押されたとき、私は次の結果しか得られないということです。
<?php Topic NOT! Successfully Created?>
次の表は、トピックテーブルの再:Table Structure from phpmyadmin
、これは全体的なデータベースのテーブル構造の一部である:Linkages of tables
は、これまでのところ私は、ブラケットの全てが適切に閉じられていることを確認することや構文を少し変更して試してみました失敗。しかし、うまくいったのは、phpmyadminを使ってデータを入力すると、何とか動作するということだけです。だから私はそのフォームにあると感じる問題。助けてもらえますか?
私はリットル原因示されているエラーは、ここでそれをテストしている何私のコードから同じ結果 –
を取得し、その作業 –
いますまだあなたがここにいたすべてのものを試してみましたかuがテストしている環境を変更してみてください –