I have a database hosted on my computer using MySQL Workbench. I have a website hosted on my computer using IIS. I have created a database fennypvp
and a table accounts
with columns id
, username
and password
. I have added multiple entries into the table from MySQL Workbench. Now I am simply trying to get these entries from the website with PHP. For now I'd simply like to be able to print the entries and from there I will work on validating credentials etc. I have look up quite a bit and nothing has worked for me. Here is what I've got so far:
<?php
$host="127.0.0.1";
$port=3306;
$socket="";
$user="root";
$password="";
$dbname="fennypvp";
$con = new mysqli($host, $user, $password, $dbname, $port, $socket)
or die ('Could not connect to the database server' . mysqli_connect_error());
$query = "select * from accounts";
if ($stmt = $con->prepare($query)) {
$stmt->execute();
$stmt->bind_result($field1, $field2);
while ($stmt->fetch()) {
printf("%s, %s\n", $field1, $field2);
}
$stmt->close();
}
$con->close();
?>
The above is code generated by MySQL Workbench although the page sql.php is blank. Any ideas? Here is the database and table information: