Hello,
Im having problem and I dont know why where it coming from, maybe you can help.
Files:
create_topic.ph p
[HTML]<form id="form1" name="form1" method="post" action="add_top ic.php">
<td>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFF F">
<tr>
<td colspan="3" bgcolor="#E6E6E 6" align="center"> <strong><font size="4">Create New Topic</font></strong> </td>
</tr>
<tr>
<td width="14%"><st rong>Topic</strong></td>
<td width="2%">:</td>
<td width="85%"><in put name="topic" type="text" id="topic" size="60" /></td>
</tr>
<tr>
<td valign="top"><s trong>Detail</strong></td>
<td valign="top">:</td>
<td><textarea name="detail" cols="50" rows="20" id="detail"></textarea></td>
</tr>
<tr>
<td><strong>Nam e</strong></td>
<td>:</td>
<td><input name="name" type="text" id="name" size="50" /></td>
</tr>
<tr>
<td><strong>Ema il</strong></td>
<td>:</td>
<td><input name="email" type="text" id="email" size="50" /></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td align="center"> <input name="id" type="hidden" id="id" value="<?$id=$_ GET['id']; echo "$id"?>">
<input type="submit" name="Submit" value="Submit" />
<input type="reset" name="Submit2" value="Reset" />
</td> <td> </td>
</tr>
</table>
</td>
</form>[/HTML]
File: Add_topic.php
[PHP]<?php
$host="localhos t"; // Host name
$username="xxx" ; // Mysql username
$password="xxx" ; // Mysql password
$db_name="cmr"; // Database name
$tbl_name="foru m_question"; // Table name
// Connect to server and select database.
mysql_connect(" $host", "$username" , "$password" )or die("cannot connect");
mysql_select_db ("$db_name") or die("cannot select DB");
// get data that sent from form
$topic=$_POST['topic'];
$detail=$_POST['detail'];
$name=$_POST['name'];
$email=$_POST['email'];
$id=$_POST['id'];
$datetime=date( "d/m/y h:i:s"); //create date time
$sql="INSERT INTO $tbl_name(topic , detail, name, email, datetime, cmrid)
VALUES('$topic' , '$detail', '$name', '$email', '$datetime','$i d')";
$result=mysql_q uery($sql);
if($result){
echo "<font size='3' face='Times New Roman'>Successf ul</font><br>";
echo "<p><a href='main_foru m.php?id={$id}' ><font size='4' face='Times New Roman, Times, serif'>View your topic</font></a>";
}
else {
echo "ERROR"; //HERE WHERE QUERY FALL
}
mysql_close();
?>[/PHP]
DISPLAY MESSAGE:
'ERROR'
Im having problem and I dont know why where it coming from, maybe you can help.
Files:
create_topic.ph p
[HTML]<form id="form1" name="form1" method="post" action="add_top ic.php">
<td>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFF F">
<tr>
<td colspan="3" bgcolor="#E6E6E 6" align="center"> <strong><font size="4">Create New Topic</font></strong> </td>
</tr>
<tr>
<td width="14%"><st rong>Topic</strong></td>
<td width="2%">:</td>
<td width="85%"><in put name="topic" type="text" id="topic" size="60" /></td>
</tr>
<tr>
<td valign="top"><s trong>Detail</strong></td>
<td valign="top">:</td>
<td><textarea name="detail" cols="50" rows="20" id="detail"></textarea></td>
</tr>
<tr>
<td><strong>Nam e</strong></td>
<td>:</td>
<td><input name="name" type="text" id="name" size="50" /></td>
</tr>
<tr>
<td><strong>Ema il</strong></td>
<td>:</td>
<td><input name="email" type="text" id="email" size="50" /></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td align="center"> <input name="id" type="hidden" id="id" value="<?$id=$_ GET['id']; echo "$id"?>">
<input type="submit" name="Submit" value="Submit" />
<input type="reset" name="Submit2" value="Reset" />
</td> <td> </td>
</tr>
</table>
</td>
</form>[/HTML]
File: Add_topic.php
[PHP]<?php
$host="localhos t"; // Host name
$username="xxx" ; // Mysql username
$password="xxx" ; // Mysql password
$db_name="cmr"; // Database name
$tbl_name="foru m_question"; // Table name
// Connect to server and select database.
mysql_connect(" $host", "$username" , "$password" )or die("cannot connect");
mysql_select_db ("$db_name") or die("cannot select DB");
// get data that sent from form
$topic=$_POST['topic'];
$detail=$_POST['detail'];
$name=$_POST['name'];
$email=$_POST['email'];
$id=$_POST['id'];
$datetime=date( "d/m/y h:i:s"); //create date time
$sql="INSERT INTO $tbl_name(topic , detail, name, email, datetime, cmrid)
VALUES('$topic' , '$detail', '$name', '$email', '$datetime','$i d')";
$result=mysql_q uery($sql);
if($result){
echo "<font size='3' face='Times New Roman'>Successf ul</font><br>";
echo "<p><a href='main_foru m.php?id={$id}' ><font size='4' face='Times New Roman, Times, serif'>View your topic</font></a>";
}
else {
echo "ERROR"; //HERE WHERE QUERY FALL
}
mysql_close();
?>[/PHP]
DISPLAY MESSAGE:
'ERROR'
Comment