Check if the value exists in the db and, if it does not exist, run update

0

What I need is to verify if in column pidio of table faucet of the database is the value true or false (the default value is false ). If it is in false , do something; if it is in true , do nothing.

This is part of my code:

case "/claim":
    $check = mysqli_query($con,"SELECT * FROM faucet WHERE telegramid = '$chatId'");
    while ($row1 = mysqli_fetch_array($check)) {
        $pidio = $row1['pidio'];
        $wallet = $row1['wallet'];
    }
    if ($pidio == 'true'){ 
        $slq2="UPDATE faucet SET pidio = true WHERE telegramid = $chatId";
        mysql_query($con,$sql2);
        sendMessage($chatId, "vuelve en 12 horas :P");
    } else { 
        $sql1="UPDATE faucet SET claims = claims + 1 WHERE telegramid = $chatId";
        $slq2="UPDATE faucet SET pidio = true WHERE telegramid = $chatId";
        mysql_query($con,$sql1);
        mysql_query($con,$sql2);
        $return2  = $shellObj->exeCmd($daemon.' getbalance '.$wallet);
        $return1  = $shellObj->exeCmd($daemon.' sendfrom '.$faucetd.' '.$wallet.' '.$faucet);
        $suma = $return1 + $return2; 
        sendMessage($chatId, "te hemos regalado ".$faucet);
        sendMessage($chatId, "el pago a sido enviado \ntu balance es ".$return2."\n se te abonaran ".$faucet."\n saldo final ".$suma);
    }
    
asked by Rodrigo 05.08.2018 в 01:42
source

1 answer

0

I recommend that you debug your code. I'm watching it and it should work. What is happening to you is that you are never entering the if but the else.

Try to see what value the $ variable brings you and I recommend that you remove the quotes ('') in the if 'true' and that 'true' is different from 1 put directly if it is equal to '1' or if it is equal to 1 or simply remove the quotes ('') to 'true' and leave it true.

Like this: if ($ pidio == true)

or so if ($ pidio == '1')

I hope I help you

Tell us.

    
answered by 05.08.2018 в 02:14