Trying to get all the users from my database, yet when I do so, the query fails.
Attempting to do so with
$userNames = mysqli_query($con, "SELECT * FROM Login");
Where in PHPMyAdmin the database has a few records in the table login. I checked if the connection is connected, its connected.
Is there any reason this wouldn't work?
Here is a examplepage, you can try logging in with Username and Password.
EDIT: From the example page, here is the code used to test:
if (mysqli_connect_errno($con)) {
echo "Failed to connect to MySQL: " . mysqli_connect_error() . "<br />";
} else {
echo "Connected to MySQL!<br />";
}
if(mysqli_query($con, "SELECT * FROM Login")){
echo "Query good!<br />";
} else {
echo "Query bad!<br />";
}
EDIT 2: Here is a screenshot of the table existing, and the data existing:
I use this
$con = StartDatabase("localhost", "username", "password", "mydatabase");
function StartDatabase($dblocation, $dbuser, $dbpasswd, $dbname){
$link = mysqli_connect($dblocation, $dbuser, $dbpasswd, $dbname);
if (!$link) {
die('Connect Error (' . mysqli_connect_errno() . ') '
. mysqli_connect_error());
}
return $link;
}
if(mysqli_query($con, "SELECT * FROM Login")){
echo "Query good!<br />";
} else {
echo "Query bad!<br />";
}
Try adding this to the else of the query to get an error output:
echo "Error code ({$con->errno}): {$con->error}";
Try like this:
$con = new mysqli("pdb1.awardspace.com", "*******", "****", "*******");
$query = "SELECT * FROM Login";
if ( !$con->query($query) ) {
echo "Query bad!<br />";
echo mysqli_connect_error() . "<br />";
echo "Error code ({$sql->errno}): {$sql->error}";
} else {
echo "Query good!<br />";
}
$con->close();