Error on php mysqli_fetch_array() -


<?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 ); 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -