Good friends I hope you can help me, I am saving data provided by the user in 2 different tables, when saving the second data I get this message Fatal error: Maximum execution time of 30 seconds exceeded
Query to Verify Existence in the DB
$conta=0;
$instruccion="SELECT rifem FROM empresa WHERE rifem = '".$rif."'";// Seleccionamos que no Exita
$instruccions="SELECT DISTINCT registrocliente.contactoc FROM proworld_cliente inner join registrocliente on(proworld_cliente.id_proworld='".$proworld."' AND proworld_cliente.id_cliente=registrocliente.id ) WHERE registrocliente.contactoc='".$comtact."'"; // Seleccionamos que no Exita
$consulta=mysqli_query($con,$instruccion) or die ("Fallo la Consulta de Empresas");
$consultas=mysqli_query($con,$instruccions) or die ("Fallo la Consulta de Cliente");
$num_resultado=mysqli_num_rows($consulta);
$num_resultados=mysqli_num_rows($consultas);
if ($num_resultado==0){
if ($num_resultados==0){
I make the first Insert in the first Table:
$instruccion1= "INSERT INTO empresa(razonsocial,rifem,referencia,direccionem) value
(UPPER('$razons'), '$rif', UPPER('$ref'), UPPER('$direcc'))";
$consultaemp= mysqli_query($con,$instruccion1) or die ("Fallo al guardar la empresas");
After having made that insert I must find the ID of that previously inserted data, I do the DO While so that it does not leave the Cycle with a Empty value because if I remove the DO WHILE the query follows its course and many sometimes it does not keep all the values or does not find that data (ID)
do{
$instruccion2="SELECT id FROM empresa WHERE rifem = '".$rif."'";
$consulta2=mysqli_query($con,$instruccion2);
while($resul=mysqli_fetch_array($consulta2)){
$idempresa=$resul[0];
}
if ($idempresa>0){$conta=1;}
}while ($conta<=0);
second insert, in this case I need that the value ($ company) is greater than 0 or you receive the data of the first insert and previously you can insert it again
$sql="INSERT INTO registrocliente(contactoc,tipoc,fechainicioc,statusc,zonac,visibilidadc,notac,precioc,diascreditoc,diastoleranciac,limitecreditoc,id_pe,tipo_pe) VALUES ('$comtact', '$tipocl', '$fechaini', '$stac', '$zona', '$visi', UPPER('$nota'), '$precio','$diascre','$diasto','$limicre', '$idempresa', '$esempresa')";
ASI WOULD SEE MY COMPLETE CODE
$instruccion="SELECT rifem FROM empresa WHERE rifem = '".$rif."'";// Seleccionamos que no Exita
$instruccions="SELECT DISTINCT registrocliente.contactoc FROM proworld_cliente inner join registrocliente on(proworld_cliente.id_proworld='".$proworld."' AND proworld_cliente.id_cliente=registrocliente.id ) WHERE registrocliente.contactoc='".$comtact."'"; // Seleccionamos que no Exita
$consulta=mysqli_query($con,$instruccion) or die ("Fallo la Consulta de Empresas");
$consultas=mysqli_query($con,$instruccions) or die ("Fallo la Consulta de Cliente");
$num_resultado=mysqli_num_rows($consulta);
$num_resultados=mysqli_num_rows($consultas);
if ($num_resultado==0){
if ($num_resultados==0){
$instruccion1= "INSERT INTO empresa(razonsocial,rifem,referencia,direccionem) value
(UPPER('$razons'), '$rif', UPPER('$ref'), UPPER('$direcc'))";
$consultaemp= mysqli_query($con,$instruccion1) or die ("Fallo al guardar la empresas");
do{
$instruccion2="SELECT id FROM empresa WHERE rifem = '".$rif."'";
$consulta2=mysqli_query($con,$instruccion2);
while($resul=mysqli_fetch_array($consulta2)){
$idempresa=$resul[0];
}
if ($idempresa>0){$conta=1;}
}while ($conta<=0);
$sql="INSERT INTO registrocliente(contactoc,tipoc,fechainicioc,statusc,zonac,visibilidadc,notac,precioc,diascreditoc,diastoleranciac,limitecreditoc,id_pe,tipo_pe) VALUES ('$comtact', '$tipocl', '$fechaini', '$stac', '$zona', '$visi', UPPER('$nota'), '$precio','$diascre','$diasto','$limicre', '$idempresa', '$esempresa')";
$query_new_insert=mysqli_query($con,$sql);