MySQL Forums
Forum List  »  PHP

PHP/MySQL Reading Database Field Help!
Posted by: Raymond Jender
Date: July 22, 2019 03:21PM

I can update the database all day, but I'm stuck trying to do a SELECT!

Here's teh database:

+----+-------------------+
| id | streamID |
+----+-------------------+
| 1 | E0ArubgkL9q2SCrXL |
+----+-------------------+
1 row in set (0.00 sec)

Here is the php:

<?php

//--------------------------------------------------------------------------
//Get the streamID from the database.
//--------------------------------------------------------------------------
$servername = "localhost";
$username = "root";
$password = "password";
$dbname = "WebRTCApp";
$tableName = "broadcast";

//--------------------------------------------------------------------------
// 1) Connect to mysql database
//--------------------------------------------------------------------------
//include 'DB.php';
//
$conn = mysqli_connect($servername,$username,$password, $dbname);
if (mysqli_connect_error()) {
echo "Failed to connect to the database!";
}

echo "Connected Successfully";

$sql = 'SELECT streamID FROM broadcast WHERE id=1';

$stream = mysqli_query($conn,$sql);
echo "<br>";
echo "stream = " $stream;
$stream1 = mysqli_fetch_field($stream);
echo "<br>";
echo "streamID = " $stream1;

mysqli_close($conn);

?>

When I browse to the php file, I get this:

Connected Successfully
stream =
streamID =

You help will be appreciated.

Ray

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.