Advertisement
TBotNik

MySQLi Numrows Errors

Jul 24th, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. All;
  2.  
  3. I have the code:
  4. #1 $sql_str = "SELECT * FROM mydb.mytab WHERE `field` LIKE '%swomething%';";
  5. #2 $dbc = new mysqli('localhost','mydb','mypass','mydb') or die(mysqli_error());
  6. #3 $dbc_res = $dbc->query ( $sql_str );
  7. #4 $qry_nrs = $dbc_res::$num_rows ( $dbc_res );
  8. #5 $qry_nrs = $dbc_res->$num_rows ( $dbc_res );
  9. #6 $qry_nrs = mysqli_num_rows ( $dbc_res );
  10. #7 $qry_nrs = $dbc_res::$num_rows;
  11. #8 $qry_nrs = $dbc_res->$num_rows;
  12. I've tried all five methods lines #4-8 and none work, but this is syntax from PHP manual, so what am I not percieving and therefore doing wrong?
  13.  
  14. Cheers!
  15.  
  16. TBNK
  17.  
  18. OK!
  19.  
  20. var_dump results:
  21.  
  22. object(mysqli_result)#3 (5) {
  23. ["current_field"]=>
  24. int(0)
  25. ["field_count"]=>
  26. int(6)
  27. ["lengths"]=>
  28. NULL
  29. ["num_rows"]=>
  30. int(0)
  31. ["type"]=>
  32. int(0)
  33. }
  34.  
  35. This is a test for existing data row so since nothing in the DB.Table NULL is the correct response.
  36.  
  37. Now assuming the error is that it can't handle the NULL.
  38.  
  39. What is the right code for handling the NULL?
  40.  
  41. Cheers!
  42.  
  43. TBNK
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement