I have really interesting problem about insert command.
I have a database consisting of two columns which are "id" and "note" and id is primary key and auto incremented.
BUT
I can't insert anything to "note" though I can insert a num to "id".
echo '<form method="POST">';
echo '<table>';
echo '<thead>';
echo '<tr>';
echo '<th class="genislik100">Yeni Not Ekle</th>';
echo '<th></th>';
echo '<th class="metinSag"></th>';
echo '</tr>';
echo '</thead>';
echo '<tbody>';
echo '<tr>';
echo '<td>Yeni Not:</td>';
echo '<td><input type="text" id="note" name="not" /></td>';
echo '<td class="metinSag"></td>';
echo '</tr>';
echo '<tr>';
echo '<td><input type="submit" name="submit" Value="Yeni Notu Ekle!!" /></td>';
echo '<td></td>';
echo '<td class="metinSag"></td>';
echo '</tr>';
echo '</tbody>';
echo '</table>';
echo '<form>';
if (isset($_POST['submit'])){
if($_POST['note'] != ''){
$note=$_POST['note'];
$con=mysql_connect("localhost","root","") or die("ERROR!!");
mysql_select_db("db") or die("COULDN'T FIND IT!!") or die("COULDN'T FIND DB");
$sql="INSERT INTO meteksan_notlar (note) VALUES ('$note')";
mysql_query($sql,$con);
echo '<script>alert("OKAY!!");</script>';
}else
echo "<script>alert('FILL THE BLANK!!');</script>";
}
I get "OKAY" alert but when I look to database, there is nothing at "note" column. WHY ??
Please help. Thanks.
or die(mysql_error())tomysql_query()to find out what errors out. Add error reporting to the top of your file(s) right after your opening<?phptagerror_reporting(E_ALL); ini_set('display_errors', 1);see if it yields anything. Doing that will help you spot the errors, of Undefined index. You can do one echo with all this, or none at all and just seperate HTML from PHP.