Page 1 of 1

Re: Hopefully an Easy one -can't get PHP MySQL Script to pull any data

Posted: Fri Aug 25, 2017 10:00 am
by hyper
The other post is probably an attempt to spam later or just get some posts?

There is no need to publish your passwords, usernames, server-name or even database-name: it isn't of use to anyone helping; simply put:

Code: Select all

$servername = "***";
$username = "***";
$password = "***";
$dbname = "***";
When you say that you can only see
0) { // output data of each row while($row = mysqli_fetch_assoc($result)) { echo "ITEM: " . $row["ITEM"]. " - Description: " . $row["DESCRIPTION"]. " " . $row["CATEGORY"]. "
"; } } else { echo "0 results"; } mysqli_close($conn); ?>
Do you mean - what is displayed in the browser window?

if so, view the source code and post that here using the [ code ] tags by using the [</>] button when you reply.

Re: Hopefully an Easy one -can't get PHP MySQL Script to pull any data

Posted: Sat Aug 26, 2017 7:37 am
by hyper
I can't see any reason for the script to go back to normal output; can you try this and let us know what happens:

Code: Select all

<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
?>

<!DOCTYPE html>
<html>
<body>

<?php
$servername = "UCTestDB2.db.9484746.c3c.hostedresource.net";
$username = "UCTestDB2";
$password = "Drowssap1!";
$dbname = "UCTestDB2";

// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
    die("Connection failed: " . mysqli_connect_error());
}


echo 'Connection made<br>';


$sql = "SELECT ITEM, DESCRIPTION, CATEGORY FROM MENUBOARD";
$result = mysqli_query($conn, $sql);


echo 'Here is the $result:<br>';
print_r ($result);
exit();


if (mysqli_num_rows($result) > 0) {
    // output data of each row
    while($row = mysqli_fetch_assoc($result)) {
        echo "ITEM: " . $row["ITEM"]. " - Description: " . $row["DESCRIPTION"]. " " . $row["CATEGORY"]. "<br>";
    }
} else {
    echo "0 results";
}

mysqli_close($conn);
?> 

</body>
</html>
Just want to see what happens to make sure it's alright.