Try using the mysqli class to work with the database.
I will give the code in object-oriented style. It is also possible to use the same code in a procedural style.
Example:
$connect = new mysqli(host,login,pass,db); $connect->query("INSERT INTO baob (arm,detk,ib) VALUES ('$did',1,'$da'), ('$arm',2,'$da');"); $connect->close();
Before that, variables
$ did, $ da, $ arm
should be escaped: either by the htmlspecialchars () method, if there will be html markup passed there or so, if just the values are passed:
$сonnect->real_escape_string($did); $сonnect->real_escape_string($da); $сonnect->real_escape_string($arm);
if you want to escape the usual values. This will avoid problems with sql injections . But even this will not always save. Described in more detail here .
//Второй вариант: $connect = new mysqli(host,login,pass,db); $connect->query("INSERT INTO baob (arm,detk,ib) VALUES('$did',1,'$da')"); $connect->query("INSERT INTO baob (arm,detk,ib) VALUES('$arm',2,'$da')"); $connect->close();
Or using prepared queries:
$connect = new mysqli(host,login,pass,db); $stmt = $connect->prepare("INSERT INTO baob (arm,detk,ib) VALUES (?,1,?), (?,2,?);"; $stmt->bind_param('ssss',$did,$da,$arm,$da); $stmt->execute(); $stmt->close(); $connect->close();
Used methods: prepare () , bind_param () ;
UPD . Added tips for using the first version of the work and a link to additional material.
echo mysql_error();and see what he writes. Well, yes, forget about the mysql extension and use mysqli or PDO - rjhdby