I am trying to use php to dynamically fill in a drop down box from a database. at the start my php file I have this before I start my html code.
<?php
include_once "queryfunction.php";
connect();
?>
The addition to this code causes a server error 500. If I comment out those two lines, the website runs (but obviously not the way I want it to). Here is my queryfunction.php code
<?php
function connect(){
$servername = "localhost";
$username = "root";
$password = "*******";
$database = "lab4";
// Create connection
$conn = new mysqli($servername, $username, $password);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
mysql_select_db($database);
}
function close(){
mysql_close();
}
function query(){
$mydata = mysql_query("Select * from Country");
while($record = mysql_fetch_array($mydata)){
echo '<option value = "' . $record['CountryAbbreviation'] . '">' . $['CountryAbbreviation'] . '"</option>';
}
}
?>
Yes I've made sure I'm using the right username, password, database, and servername. I'm using amazon instant web service if that helps. I did the actions to turn on displaying errors in php but i still get no info besides server error 500 when the page doesn't run. Thanks guys