Error on php mysqli_fetch_array() -
this question has answer here:
<?php $connection = mysqli_connect( "localhost", "gari" , "gari" , "onlinemarket" ); $call = "select * products id ='". 4 ."'"; $result = mysqli_query( $connection , $call ); while ( $row = mysqli_fetch_array( $result ) ) { $call = "update products set stock = '". 666 ."' id ='". 4 ."'"; $result = mysqli_query( $connection , $call ); } mysqli_close( $connection ); ?>
the real problem in $row = mysqli_fetch_array( $result )
, receive this:
mysqli_fetch_array() expects parameter 1 mysqli_result, boolean given in c:\xampp\htdocs\tiendaonline\php\prueba.php on line 12 dont know how use mysqli_error() error.
thank you.
looks inner loop replaces $result
, while loop makes no sense if not using $row
inside loop. try following code
<?php $connection = mysqli_connect( "localhost", "gari" , "gari" , "onlinemarket" ); $call = "select * products id ='". 4 ."'"; $result = mysqli_query( $connection , $call ); while ( $row = mysqli_fetch_array( $result ) ) { $call = "update products set stock = '". 666 ."' id ='". 4 ."'"; $resultupdate = mysqli_query( $connection , $call ); } mysqli_close( $connection ); ?>
if need update record no need select query use following code.
$call = "update products set stock = '". 666 ."' id ='". 4 ."'"; $resultupdate = mysqli_query( $connection , $call ); mysqli_close( $connection );