Page 1 of 1

how do i insert data to mysql

Posted: Tue Aug 13, 2002 5:10 am
by harsha
<?php

$db=mysql_connect("127.0.0.1","hi","getche");
mysql_select_db("jawab",$db);
if ((isset($jname)) AND (isset($jemail))) {
$sql="INSERT INTO jawab VALUES('$jid','$jname','$jemail','$jdate','$jcomment')";
$result=mysql_query($sql,$db);

$jdate=date(M,d,Y);
echo "data inserted";
}
?>

<form method=POST action="/jawab/index.php">
<INPUT TYPE="text" NAME="jname">
<br>
<input type=text name=jemail ><br>
<textarea cols=30 rows=8 name=jcomment ></textarea>
<input type=submit name=submit value=add>
</form>


i am using this but it is not working plz help me :?

Posted: Tue Aug 13, 2002 5:20 am
by Wayne
what errors are you getting? or what is happening?

Posted: Tue Aug 13, 2002 5:25 am
by Geschi
Ok, there are some points to discuss:
1. The table "jawab" has the same name as the database? Maybe you mispelled something.
2. Better put
$jdate=date(M,d,Y);
before your SQL query
AND this is the right way to use date():

Code: Select all

$jdate=date("M d Y");

Posted: Tue Aug 13, 2002 6:42 am
by twigletmac
If you have a problem with some code please:
  • Tell us what isn't working;
  • Give any error messages you are receiving;
  • Explain what your code is trying to do.
This makes it easier for us to help you and means we don't have to go through each part of your code and can concentrate on the parts that are throwing up errors.[/list]

To summarise, posting some code, asking for help and giving no additional information is rude.

Mac