MySQL Forums
Forum List  »  PHP

Re: PHP/MySQL Reading Database Field Help!
Posted by: Raymond Jender
Date: July 23, 2019 12:06PM

Peter Brawley Wrote:
-------------------------------------------------------
> DId you add a line to see if the query returns any
> rows? What's the result of mysqli_num_rows($conn)
> ?
>
> Check the PHP manual ... mysqli_fetch_field()
> fetches column info, not data---which needs
> mysqli_fetch_row().

I have this:

$sql = "SELECT streamID FROM broadcast WHERE id=1";
if ($result = mysqli_query($conn, $sql)) {
$row = $result->fetch_assoc();
echo "row = ", $row;
37: $row = $result->mysqli_num_rows($conn);
echo "row2 = ", $row;
// $sql = 'SELECT id FROM broadcast WHERE streamID = E0ArubgkL9q2SCrXL';
// $stream = mysqli_query($conn,$sql);


if( !$row) {
$err = mysqli_error( $conn );
logerr( $err );
if( $debug ) echo "Error: $err<br>" };
}

Which returns this:

Connected Successfully
row = Array /usr/local/antmedia/webapps/php/getstreamID.php:37: Fatal Error: Call to undefined function mysqli_num_rows (I show line 37)

Perhaps I should have mentioned I am not a mysql or php programmer. I am a learn as I go kinda guy. I'd much rather struggle a little and if I can't fix my problem, seek help.

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.