+ 2

Warning: mysqli_query() expects parameter 1 to be mysqli, bool given i.... WHY THIS ERROR ARRIVE BASICALLY I WHAT TO KNOW

can I know what is the problem with this code? I got this error every time with this query function. <?php $con = mysqli_connect("localhost","root","","voting") || die("not connected"); echo "connected"; if(isset($_POST['ele'])){ global $con; $vote_ele = "update votes set ele = ele + 1"; $run = mysqli_query($con,$vote_ele); if($run){ echo "voted to electronics"; } else{ echo mysqli_error($run); } } ?>

7th Jul 2019, 6:37 AM
srinu rocky
srinu rocky - avatar
5 ответов
+ 3
thank you Drax
7th Jul 2019, 7:39 AM
srinu rocky
srinu rocky - avatar
+ 1
Remove || die(... ) It cast the whole expression to a boolean, whilst con needs to be a mysqli object
7th Jul 2019, 7:24 AM
Drax
Drax - avatar
0
yeah i did it so finally i understood that after confirming dbs is connected we should remove die().Because i effects on mysqli_query()
7th Jul 2019, 7:37 AM
srinu rocky
srinu rocky - avatar
0
while define global $conn now its working thanks
17th Apr 2020, 7:04 PM
mak gurung
mak gurung - avatar
0
Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in /storage/ssd1/839/12482839/public_html/login.php on line 17
21st Apr 2020, 6:24 AM
simeon