3
I’m following a toturial, it’s all the same. My problem is I can’t connect to the table.
connect.php:
<?php
$db = new mysqli('127.0.0.1', 'user', 'pass', 'app');
if ($db -> connect_errno) {
die ('Sorry, we are having some problems.');
}
?>
This works correctly, the connection to DB is made without probs.
The problem is here:
index php.
<?php
require_once('db/connect.php');
$result = $db->query("SELECT * FROM people") or die ($db->error);
if ($result->num_rows) {
echo 'yay';
}
?>
The query gives this error message being this:
Table 'app.people' doesn’t exist
Being that, only people
is the table name
In your php instead of
select ... people
change toshow tables
and see if the table will appearpeople
. When in doubt try to recreate her.– rray
"Yay, "I think that’s a good sign.... Although I don’t understand what’s going on in this case...
– Miguel
you need a forech on
$result
or aprint_r()
to see the result of the consultation.– rray
Miguel, but it comes to "Yay" or not?
– bfavaretto
Yes, with 'show Tables' arrived.
– Miguel
'print_r($result)' = "mysqli_result Object ( [current_field] => 0 [field_count] => 1 [lengths] => [num_rows] => 1 [type] => 0 ) ".... is wrong
– Miguel
Could be permission issue, tried to access with the root user of your mysql?
– bfavaretto
I’ve also thought about it, but I don’t think so... Permission is on the www-data side (linux)
– Miguel