0

I am trying to read the data from Amazon RDS database and print out the result of the query. However when I try to read the query in php and print the result it prints the actual code instead of the the result. Can someone please help me. Here is my code.

<!DOCTYPE html>
<html><body><pre><code><?php




$host = "myhost";
$db = "database";
$user = "user";
$pass = "password";

$link = mysqli_connect($host,$user,$pass, $db);

$query = "SELECT * FROM my_project1.all";
$results = mysqli_query($link, $query);



if(mysqli_num_rows($result >=1)){
    echo '<table class= "table table-striped table-bordered table-hover">';
    echo "<tr><th>Name</th><th>City</th><th>State</th></tr>";

    while($row = mysqli_fetch_array($result)){
        echo "<tr><td>";
        echo $row[0];
        echo "</td><td>";
        echo $row[1];
        echo "</td><td>";
        echo $row[2];
        echo "</td></tr>";
    }
    echo "</table>";
}
 else {
     echo "There was no match found";
}


include 'index.php';

?></code></pre></body></html>

And I am calling this States.php file into index.php with the following code

<nav id="navigation">
    <ul id="nav">
        <li><a href="States.php">States</a></li>
    </ul>

</nav>
    </section>
Abp
  • 113
  • 5
  • 26
  • 1
    Okay, with the update just look at the linked thread. You also could remove 4/5 of those tags by replacing the `mysqli` code with `echo 'hello world';` to see if the DB issues are related at all. – chris85 Nov 22 '16 at 00:17
  • if you see the PHP script then your web server is not parsing the PHP file.. This is a problem with server configuration, not your script (although there may be scripting errors, we can't know since the script has never actually "ran" before – Duane Lortie Nov 22 '16 at 00:18
  • comment out first your `if_else` and just after the link line, add something like `if($link) {echo "something";}` just to make sure you're connected to database or what. – claudios Nov 22 '16 at 00:21

0 Answers0