-
Help on SQL query
Hello everybody
I have tried folloing sql. is is correct way to write querry. Please suggest
$sql_artist = "INSERT INTO tblartist (ArtistName) VALUES ('$artist')";
$sql_barcode = "INSERT INTO tblcollection (barcode) VALUES ('$barcode')";
$sql..........
$sql..........
.
.
.
$result = mysql_query($sql_artist.$sql_barcode,$sql.........., $sql.........., );
Thaks in Advance
Ramesh chaudahry
-
Re: Help on SQL query
mysql_query will only execute one query at a time, aside from sub selects. You need to call each query using mysql_query. I would suggest using an array:
PHP Code:
$queries = Array("INSERT INTO tblartist (ArtistName) VALUES ('$artist')",
"INSERT INTO tblcollection (barcode) VALUES ('$barcode')");
foreach($queries as $query) {
$result = mysql_query($query);
if (!$result) {
echo(mysql_error()); // also, use error checking to filter out bad queries
}
}
-
Re: Help on SQL query