Author Topic: php error when using mysqli or mysql  (Read 854 times)

Offline 133794m3r

  • Level 22
  • *
  • Posts: 265
  • Reputation: +2/-0
    • View Profile
php error when using mysqli or mysql
« on: February 23, 2011, 08:04:24 AM »
PHP Warning:  mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given
mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given

Code: [Select]
$res=mysqli_query($conn,$query);
$row=mysqli_fetch_array($res, MYSQLI_BOTH);
mysqli_free_result($res);

the same thing is still happening in mysqli, but for some reason php is throwing errors even though, that is exactly what the PHP developers say to do it on their own pages.

Why is it throwing warnings when that way works, and it's exactly what PHP says to do it.

Offline CygnusX

  • Level 24
  • *
  • Posts: 303
  • Reputation: +3/-2
    • View Profile
    • Lords of Midnight
Re: php error when using mysqli or mysql
« Reply #1 on: February 23, 2011, 08:36:16 AM »
It seems you are not showing all of your code.  Where do you establish $conn?

Offline DV8

  • Level 10
  • *
  • Posts: 63
  • Reputation: +0/-0
    • View Profile
    • Shadowrun: Corrosion
Re: php error when using mysqli or mysql
« Reply #2 on: February 23, 2011, 09:01:42 AM »
And is your query valid? If it isn't then $res also isn't valid. It will return false, a boolean, which is what mysqli_fetch_array() is throwing errors for.

Offline Winawer

  • Level 6
  • *
  • Posts: 27
  • Reputation: +0/-0
    • View Profile
Re: php error when using mysqli or mysql
« Reply #3 on: February 23, 2011, 09:04:22 AM »
The mysqli_query failed, so there's probably an error in the SQL. See http://www.php.net/manual/en/mysqli.error.php

Offline 133794m3r

  • Level 22
  • *
  • Posts: 265
  • Reputation: +2/-0
    • View Profile
Re: php error when using mysqli or mysql
« Reply #4 on: February 23, 2011, 09:26:23 AM »
nvm all of that, it seems that i mistyped my tables name and since i currently have no actual data in it(it's ran even though it's not needed right now since it's a test mostly of things) it seems to be failing. This can be closed yada yada yada. forgot an 's' at the end of it.

 


SimplePortal 2.3.3 © 2008-2010, SimplePortal