Re: insert data in mysql table
| From: | Andy Ladouceur | Date: | Sun, 11 Apr 2004 06:30:51 +0000 |
| Subject: | Re: insert data in mysql table | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-33843@lists.php.net to get a copy of this message | ||
From what I can see, the order that you created the table with and the order of the fields in the query do not match up. Changing the query to:
$add_all = "INSERT INTO $table values('','$name','$day','$question','$email','')";
Should make things run just fine.
Cheers,
Andy
Charalambos Nicolaou wrote:
Hi everyone ,I have created this Mysql tableCREATE 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