Posts: 41
Name: Jabis Sevon
Location: Tampere, Finland
|
Quote:
Originally Posted by [b]lackwater
Code:
Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in /homepages/31/d231284211/htdocs/home/editor/editor.php on line 22
|
You have the error stated right in front of you, you're passing a boolean (true|false) parameter to the fetch_array instead of an SQL resultset from the db.
Try something like this
PHP Code:
$DBConnect = mysqli_connect("host", "user", "password", "db"); /* first check the connection, do this always! */ if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); }
$sql = "SELECT * FROM Content WHERE Page = 'Staff'"; /* try it like this */ if ($AboutUsResult = mysqli_query($DBConnect, $sql)) {
/* return the numeric array */ $row = mysqli_fetch_array($AboutUsResult, MYSQLI_NUM); printf ("%s (%s)\n", $row[0]);
} else { printf("Error: %s\n", mysqli_error($DBConnect)); } /* when you're done free the resultset */ mysqli_free_result($AboutUsResult);
/* close connection */ mysqli_close($DBConnect);
The other possible thing could be that your query doesn't return a resultset, to think of it, but to test it, you should do like follows:
PHP Code:
if(mysqli_query($DBConnect, $sql) === TRUE) { printf("successfully queried.\n"); } else { printf("query failed.\n"); }
Last edited by jabis; 10-23-2008 at 01:25 PM..
Reason: **** typos
|