Currently, I am trying to work on adding a webpage on Amazon Web Services. The web page contains PHP and HTML code intended to display a particular table from my local MySQL database. I have already created an EC2 instance and a AWS RDS instance, however, there is a problem that is happening consistently which is bothering me. On my computer's local host through MySQL, the code to display all records of a table was this:
SELECT * from Students, StudentProfile, Job
WHERE Students.StudentID=StudentProfile.Students_StudentID and Students.StudentID=Job.Students_StudentID;
Based from the above code, this executes perfectly and I did confirmed this by doing the same procedure at the MySQL Workbench. However, upon uploading my file called "projectview.php" (the .php file to view all records of a table) onto AWS, it doesn't work. I was aware that I knew I had to change parts of my code for connecting it to AWS's RDS instance. As a result, I followed the tutorial example in creating a sample page based from a tutorial in AWS. Below of this contains a sample .php file that contains my current work for a website to display.
<HTML>
<HEAD>
<TITLE>List Students</title>
<link href="https://fonts.googleapis.com/css?family=Varela+Round" rel="stylesheet">
<style>
body {font-family: 'Varela Round', sans-serif;
background-color: #ffddcc;
color: #e64d00;
border: 2px solid #ff7733;
border-radius: 10px;
}
h1 {font-family: Georgia, serif;}
input {color:#e64d00;}
</style>
</head>
<BODY>
<H1>List Students</h1>
<?php include '../inc/dbinfo.inc';
$conn = @mysqli_connect("DB_SERVER","DB_USERNAME","DB_PASSWORD","DB_DATABASE" );
if($conn->connect_error) {
die("Connection failed:" . $conn->connect_error);
}
else
{
echo "Status:Connected.";
echo "<br>";
}
$sql = "SELECT * from Students, StudentProfile, Job
where Students.StudentID=StudentProfile.Students_StudentID and Students.StudentID=Job.Students_StudentID";
mysql_select_db("project2");
$result = mysqli_query($conn, $sql);
if(!$result) {
die('Could not get data: ' .mysql_error());
}
while($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo "<br>";
echo "StudentID: " . $row["studentID"]. "<br>";
echo "First Name: " . $row["firstName"]. "<br>";
echo "Last Name: " . $row["lastName"]. "<br>";
echo "Major: " . $row["Major"]. "<br>";
echo "Level: " . $row["Level"]. "<br>";
echo "Address: " . $row["Address"]. "<br>";
echo "City: " . $row["City"]. "<br>";
echo "Country: " . $row["Country"]. "<br>";
echo "Zipcode: " . $row["Zipcode"]. "<br>";
echo "Phone: " . $row["Phone"]. "<br>";
echo "Job Company: " . $row["Job_Company"]. "<br>";
echo "Job Title: " . $row["Job_Title"]. "<br>";
}
echo "Fetched data successfully\n";
//$result = $conn->query($query);
$conn->close();
?>
<br>
<FORM METHOD="LINK" ACTION="project2mainmenu.html">
<INPUT TYPE="submit" VALUE="Return to Main Menu">
</form>
</body>
</html>
Furthermore, I noticed that when I check at my web page after running the code, it shows an image like this:
****Note: I already uploaded all my related files for the particular web pages. Also, this web page is not affiliated with any other files. It is a stand-alone file.**