Welcome to the JaguarPC Community
JaguarPC
Sales: (888) 338-5261
Support: (888)-551-3050
Results 1 to 4 of 4

This is a discussion on mysqli trouble after switch to PHP 5 in the Open Discussion & Chit-chat forum
I've just had my account moved to a server running PHP 5 and am having some difficulty with the mysqli functions. Here's the message I'm ...

  1. #1
    JPC Addict
    Join Date
    Feb 2002
    Posts
    140

    mysqli trouble after switch to PHP 5

    I've just had my account moved to a server running PHP 5 and am having some difficulty with the mysqli functions. Here's the message I'm getting:
    Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in /home/mydir/public_html/mysite/usr/index.php on line 15
    Here are lines 8-15:
    PHP Code:
    $dbcnx mysqli_connect('localhost'$_SESSION['db_username'], $_SESSION['db_pass'], $_SESSION['dbname']); 

    /* check connection */
    if (!$dbcnx) {
       
    printf("Connect failed: %s\n"mysqli_connect_error());
       exit();
    }
        
    $sql "SELECT * FROM `regions` LIMIT 1";
          
    $result mysqli_query($dbcnx$sql);
        
    $regions mysqli_fetch_array($resultMYSQLI_BOTH); 
    I've checked the PHP manual for mysqli_fetch_array() and the above seems to conform to the right syntax. Wouldn't '$result = mysqli_query($dbcnx, $sql);' give the 'mysqli_result' expected, instead of the 'boolean given'? Can anyone see the trouble?

    Thanks!
    Last edited by soundser; 02-10-2006 at 03:58 AM.

  2. #2
    the Windlord Gwaihir's Avatar
    Join Date
    Jun 2002
    Posts
    2,562
    Isn't it the other way around? I.e. I think the error means it was expecting a boolean there but not getting one. The boolean that would result if you were to run mysqli_real_query() instead of mysqli_query().
    Regards,

    Wim Heemskerk
    ---
    Visit MeCCG.net - Cardgaming in J.R.R. Tolkien's Middle-earth
    And Gwaihir.net - The Middle-earth CCG store

  3. #3
    Community Leader jason's Avatar
    Join Date
    Sep 2001
    Location
    Rochester, NY
    Posts
    6,003
    Try adding this line after the mysqli_connect() statement:

    PHP Code:
    echo('<pre>');print_r($dbcnx);echo('</pre>'); 
    That will dump the contents of the $dbcnx variable to the browser so you can see what it is and what type of data it contains. When I'm dealing with objects I find this trick invaluable in diagnosing problems.

    You may also try changing the if(!$dbcnx) statement with if($dbcnx === false). (Note the 3 "=" signs, which forces PHP to compare data type and value instead of just value). It shouldn't make a difference, but it is worth a try.

    --Jason
    Jason Pitoniak
    Interbrite Communications
    www.interbrite.com www.kodiakskorner.com

  4. #4
    JPC Addict
    Join Date
    Feb 2002
    Posts
    140

    Thanks

    Wim Heemskerk and Jason,

    Thanks for your replies. I've gotten past this warning now but I have much updating to do to get my pages functioning again. I'll post again when I'm further along.

    -soundser

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •