i'm beginner and i couldn't solve the problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I'm usin php, apache and mysql on my computer. I have run some scripts. so i'm sure i installed them correctly. One of my script don't run properly, also it doesnt give error. 
I'm trying to send some data to my database by using a form. The database can get the auto incremented number but doesn't get whatever I type into the text box in the form. My code is below:
------------------------------------------------------
<?php
//open the connection
$conn = mysql_connect("localhost", "selimatmaca", "BETULBETUL");
//pick the database to use
mysql_select_db("testDB", $conn);
//create the sql statement
$sql = "INSERT INTO testTable values ('', '$_POST[testField]')";
//execute
if (mysql_query($sql,$conn)){ 
echo "Record Added";
} else{ 
echo "Somethin went wrong";
}
?>
--------------------------------------------------------------
 
 
mysql> select * from testTable;
+----+--------------+
| id | testField    |
+----+--------------+
|  1 | some value   |
|  2 | some value   |
|  3 |                    |
|  4 |                    |
|  5 |                    |
|  6 |                    |
|  7 |                    |
|  8 |                    |
|  9 |  [testField]    |
| 10 | [testField]    |
| 11 |                    |
| 12 |                    |
| 13 |                    |
| 14 |                    |
+----+--------------+
14 rows in set (0.00 sec)
 
 
The database dont show the "testField" data, but it shows the numbers.
Also this is my html form:
 
 
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>An Insert Form</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<FORM ACTION="insert.php" METHOD=POST>
<P> Type something in:<br>
<input type=text name="testField" size=30>
<input type="submit" name="submit" value="Insert Record">
</P>
</FORM>
</body>
</html>

 
 There is another script for which I dont use a html form. I send the data directly from the script and it works fine. Codes are here: 
 
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
$conn = mysql_connect("localhost", "selimatmaca", "BETULBETUL");
mysql_select_db("testDB", $conn);
$sql = "INSERT INTO testTable values ('', 'some value')";
if (mysql_query($sql, $conn)) 
 {
 echo "record added";
 } 
 else 
 {
 echo "Something went wrong";
 }
?>
</body>
</html>

 
so, please tell me where I'm doing wrong. Thanks a lot.

		
---------------------------------
Do you Yahoo!?
 Yahoo! Mail - Find what you need with new enhanced search. Learn more.

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux