insert data in mysql table
| From: | charalambos nicolaou | Date: | Sat, 10 Apr 2004 23:39:38 +0000 |
| Subject: | insert data in mysql table | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-33842@lists.php.net to get a copy of this message | ||
Hi everyone ,
I have created this Mysql table
CREATE TABLE questions (ID INT NOT NULL AUTO_INCREMENT, name VARCHAR(25), day DATE, question TEXT, email VARCHAR(30), PRIMARY KEY(ID));
And I am trying to insert data in it using the following
<body>
<?
if(isset($_GET['commented']))
{
echo("Your comment has been posted.");
$host = "********";
$user = "******";
$pass = "*****";
$db = "******";
$table = "questions";
$name = $_GET['form_uname'];
$question = $_GET['form_quest'];
$day = $_GET['form_day'];
$email = $_GET['from_email'];
mysql_connect($host,$user,$pass) or die(mysql_error());
mysql_select_db($db) or die(mysql_error());
$add_all = "INSERT INTO $table values('$name','$question','$day','$email','')";
mysql_query($add_all) or die(mysql_error());
}
else
{
?>
<form method="get" action="<? echo "$PHP_SELF " ; ?>" >
Name : <input type="text" name="form_uname">
<p>Question :<textarea rows="3" name="form_quest" cols="36"></textarea></p>
<p><br>
Date: <input type="text" name="form_day">
</p>
<p>Email: <input type="text" name="form_email"><br><br>
<input type= "hidden" name= "commented" value= "set" >
<input type="submit" value="Submit">
</p>
</form>
<?php
}
?>
</body>
Finally has a result to get the correct data only for the DATE and the data from the Question FORM goes to the name field. I do not know where the problem is. Help me please because I am going crazy,
Thanks in advance
Charalambos Nicolaou
_________________________________________________________________
STOP MORE SPAM with the new MSN 8 and get 2 months FREE* http://join.msn.com/?page=features/junkmail