-1
I have this code to receive data on two different tables. But only the first table is receiving data. The second table is still blank. It is possible for this code to work this way?
if(($query=mysql_query($sqlinsert)) and ($query2=mysql_query($sqlinsert2))){
$sqlinsert = "INSERT INTO tb_funcoes VALUES(0,'"....)";
$sqlinsert2 = "INSERT INTO tb_detalhe_trabalhador VALUES(0,NULL,NULL,'o."',....)";
}
When the error occurs, returns the following message:
Duplicate entry '0' for key 'PRIMARY'
The second query returns error? you better take both
mysql_query
if and addor die(mysql_error())
in the end. Beware also ofand
and&&
because they both have different priorities Logical operators– rray
Strange this check. The rest of your code should make sense of this test. But recommend for an OR DIE at the end of each query and read the return.
– Luiz Picolo
If the first query is being successfully executed, it means that the condition is being valid. The SQL of your second query is exactly this?
– Ricardo
$sqlinsert
and$sqlinsert2
should not be before theif
?– rray
Exactly. I copied the old code. the $sqlinsert and $sqlinsert2 are before the if
– ChrisAdler
@user3253195, tried one query at a time? which error message returned?
– rray
"If(($query=mysql_query($sqlinsert)) and ($query2=mysql_query($sqlinsert2))){ }" ())"
– ChrisAdler
thus without the
if
,mysql_query('select.....') or die(mysql_error());
– rray
Duplicate entry '0' for key 'PRIMARY'
– ChrisAdler