I am currently learning MySql, but ive hit this issue. The following code should just query db for everything that is in the users table. but he returns this error. Error: SELECT * FROM users , which doesn't help me at all. I can successfully insert an item into the database, but I cannot select it. I also tried $sql = "SELECT * FROM ama.users"; my db structure
ama |-users
any help would be greatly appreciated.
$conn = new mysqli($_ENV['OPENSHIFT_MYSQL_DB_HOST'],$_ENV['OPENSHIFT_MYSQL_DB_USERNAME'], $_ENV['OPENSHIFT_MYSQL_DB_PASSWORD'], 'ama'); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $username = "Doe"; $password = "johnexample"; $sql = "SELECT * FROM users"; if ($conn->query($sql) === TRUE) { echo "New record created successfully"; } else { echo "Error: " . $sql . "<br>" . $conn->error; } $conn->close();
source share