hi
I put this code in my page , line 21 do correct , but line 22 don't put data in my database . I'm sure that my database and table is exist .
please help me .
thanks

php:

<?PHP
1 mysql_connect("localhost", "username", "Password")
2 or die("Could not connect");
3 mysql_select_db("Database") or die(mysql_error());
4
5 $tooday = date("Ymd");
6 $coname = $HTTP_POST_VARS["CoName"];
7 $name = $HTTP_POST_VARS["Name"];
8 $birth = $HTTP_POST_VARS["Year"] . "-" . $HTTP_POST_VARS["Month"] . "-" . $HTTP_POST_VARS["Day"];
9 $pname = $HTTP_POST_VARS["FName"];
10 $shenas = $HTTP_POST_VARS["ShNumber"];
11 $fishnum = $HTTP_POST_VARS["FishNumber"];
12 $payday = $HTTP_POST_VARS["byear"] . "-" . $HTTP_POST_VARS["bmonth"] . "-" . $HTTP_POST_VARS["bday"];
13 $bank = $HTTP_POST_VARS["BankCode"];
14 $add = $HTTP_POST_VARS["Address"];
15 $tel1 = $HTTP_POST_VARS["Tel1"];
16 $tel2 = $HTTP_POST_VARS["Tel2"];
17 $curmail =$HTTP_POST_VARS["CurEmail"];
18 $ph1 = $HTTP_POST_VARS["FEname"];
19 $ph2 = $HTTP_POST_VARS["SEname"];
20 $password = $HTTP_POST_VARS["FPass"];

21 mysql_query("INSERT INTO FreeEmail (Rdate,ShNumber,Name1,Name2,Pass) VALUES ('$tooday','$coname','$name','$shenas','$tel1')");

22 mysql_query("INSERT INTO mailSale (aRdate,aCompany,aSName,aBirthday,aPName,aShenas,a
FishNum,aPayDate,aBank,aAdd,aTell1,aTell2,aCurMail
,aPh1,aPh2,aPassword) VALUES ('$toodat','$coname','$name','$birth','$pname','$s
henas','$fishnum','$payday','$bank','$add','$tel1'
,'$tel2','$curmail','$ph1','$ph2','$password')");

?>

    I would suggest making a couple of changes
    Lines 1-20 are OK as is, now change lines 21+ to:

    $insert_sql1 = "INSERT INTO FreeEmail (Rdate,ShNumber,Name1,Name2,Pass) VALUES ('$tooday','$coname','$name','$shenas','$tel1')"; 
    $result_1 = mysql_query($insert_sql1) or die("Error in 1st INSERT statement ($insert_sql1)<BR>".mysql_error()");
    $insert_sql_2 = "INSERT INTO mailSale (aRdate,aCompany,aSName,aBirthday,aPName,aShenas,aFishNum,aPayDate,aBank,aAdd,aTell1,aTell2,aCurMail,aPh1,aPh2,aPassword) VALUES ('$toodat','$coname','$name','$birth','$pname','$shenas','$fishnum','$payday','$bank','$add','$tel1','$tel2','$curmail','$ph1','$ph2','$password')"; 
    $result_2 = mysql_query($insert_sql_2) or die("Error in 2nd INSERT statement ($insert_sql_2)<BR>".mysql_error()");
    

    Basically this will run the queries, but if any errors occur running the queries it will output an error message containing the SQL error. An SQL error may be the cause of the failure of your line 22 to insert anything. As it stood your script wasn't trapping any errors.

    Hope this helps.

    Jamie

      thanks
      i put this code in my page and then publish .
      but my page don't output an error message .

      and line 21 put data in database but line 22 don't put data in database .

        Write a Reply...