www.webdeveloper.com
Results 1 to 2 of 2

Thread: PHP Function

  1. #1
    Join Date
    May 2007
    Location
    London, United Kingdom
    Posts
    430

    PHP Function

    What am I doing wrong with this simple function? The code works above the <hr> tag, but I get a: Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, null given... Error when using the function.

    PHP Code:
    <?php

    function database_query($query_name$database_query){
     global 
    $dbc;
     
    $query_name mysqli_query($dbc$database_query) or die("Problem Querying ".mysqli_error($dbc));
    return 
    $query_name;
    }

    $comment_count "SELECT * FROM comments WHERE photo_id = $image_id";
    $count_comments mysqli_query($dbc$comment_count) or die("Problem");
    echo 
    mysqli_num_rows($count_comments);
        
    echo 
    "<hr />";

    database_query($count_comments$comment_count);
    echo 
    mysqli_num_rows($count_comments);

    ?>
    Thanks in advance

  2. #2
    Join Date
    May 2007
    Location
    London, United Kingdom
    Posts
    430

    Must be tired...

    Time for a cuppa coffee.

    I got it sorted. Simple fix, just as I thought it might be.

    PHP Code:
    $test database_query($count_comments$comment_count);
    echo 
    mysqli_num_rows($test); 

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles