tags:

views:

161

answers:

1

error message: oci_fetch_array() expects parameter 1 to be resource, boolean given in /url_fns.php on line 17
I want to get all bm_URL record and store in $url_array. echo $r is shown to be 1. How to fix this error message?


$conn = db_connect();

  $result = oci_parse($conn, "select bm_URL
                          from bookmark
                          where username = '$username'"); 
  if (!$result){
    $err = oci_error(); 
  exit;
  }
  $r = oci_execute($result);
  if (!$r) {
   $error = oci_error($conn);
  exit;
  }

  //create an array of the URLs

  $url_array = array();
  for($count = 1; $row = oci_fetch_array($r); ++$count) // error
  {
    $url_array[$count] = $row[0];  
  }  
  return $url_array;
A: 

oci_fetch_array($result) instead of oci_fetch_array($r)


Also, try this when fetching:

  $url_array = array();
  while ($row = oci_fetch_array($r))
  {
    $url_array[] = $row[0];  
  }  
  return $url_array;

If $url_array is empty then the query did not return any results.

pygorex1
error message solved, do you know why echo $url_array appear to be no value? what's wrong with the logic?
monday.c
See the edited response. Might also trying `echo()` on the SQL statement and see the results when you execute it within the database.
pygorex1