0
this is my 'Betting Signup Method' on my betting system.
In this way, I register data in two tables, a call BET and another BET_MATCHES, the system is controlled by time, so in all entries I need to set the TIME_ZONE = '-03:00' to make sure there will be no error at the time, and right after that run the query that registers the header and generates the bet ID.
Only when I rescue the last id generated in this multi_query the code returns me = 0... what can I do ?
public function setBet($punter_name, $punter_phone, $value, $colab_id, $array_matches)
{
// Post Header and Catch Bet ID
$query = "SET TIME_ZONE = '-03:00';";
$query .= "INSERT INTO bet SET id ='NULL',
punter_name ='$punter_name',
punter_phone ='$punter_phone',
value ='$value',
colab_id ='$colab_id',
date_time = now()";
$data = mysqli_multi_query(Conexao::conectar(), $query) or die(Conexao::conectar());
// For if data True, registered Header
if ($data){
// Get the id what we want
$query = "SELECT LAST_INSERT_ID() FROM bet";
$data = mysqli_query(Conexao::conectar(), $query);
$line = mysqli_fetch_assoc($data);
var_dump($line);
}
else
echo "There was an error when registering the bet header";
}
You really need the
multi_query()
?– rray
@rray accurate because of the SET TIME_ZONE = '-03:00'; before the Insert it needs to have the exact time of Brazil so that there is no error in the betting conference
– Yuri Foxx
you can play this in the server configuration if you want.
– rray
@rray is that I am hosting the system in a shared server which I do not have Super User power in the database, and let’s say that because it is a system that moves values in betting based on schedules, I can say that the more sure the better ?
– Yuri Foxx
PHP is not mine, but when you call "Connected::connect()" are you not creating a session with the database? If so, then your INSERT and SELECT are not in different sessions and so you don’t get the feedback? In this case, you should create the connection before INSERT and use it for SELECT as well, then close.
– lpacheco
@lpacheco I will test and put here if it works ! but I liked your answer !
– Yuri Foxx