Note that there are some explanatory texts on larger screens.

plurals
  1. PONo database selected
    primarykey
    data
    text
    <p>I have created a 'db.php' file where I make a connection to my db:</p> <pre><code>$db_user = 'usprojus'; $db_pass = 'xxxxxx'; $db_host = 'localhost'; // Verbinden $dblink = mysqli_connect($db_host, $db_user, $db_pass); // Datenbank "myproject" auswaehlen // Entspricht "USE myproject;" $selected = mysqli_select_db($dblink, 'myproject'); if (!$selected) { die ('Cannot use DB : '.mysqli_error($dblink)); } mysqli_set_charset($dblink, 'utf8'); </code></pre> <p>In order to test that is working I am trying to get data from my 'users' table:</p> <pre><code>require_once('db.php'); // Get all the data from the "users" table $result = mysql_query("SELECT * FROM users") or die(mysql_error()); // keeps getting the next row until there are no more to get while($row = mysql_fetch_array( $result )) { // Print out the contents of each row into a table echo 'user_id: '.$row['user_id'].'&lt;br /&gt;'; echo 'date_registered: '.$row['date_registered'].'&lt;br /&gt;'; echo 'last_login: '.$row['last_login'].'&lt;br /&gt;'; echo 'username: '.$row['username'].'&lt;br /&gt;'; echo 'email: '.$row['email'].'&lt;br /&gt;'; echo 'password: '.$row['password'].'&lt;br /&gt;'; echo 'photo: '.$row['photo'].'&lt;br /&gt;'; echo 'description: '.$row['description'].'&lt;br /&gt;'; echo 'notify: '.$row['notify'].'&lt;br /&gt;'; } </code></pre> <p>But I get this error in the browser:</p> <blockquote> <p>No database selected</p> </blockquote> <p>For the life of me I cannot figure out where the problem lies.</p> <p>Sorry, I know this is a newbie question, and it seems it has been posted here several times. But I could not figure it out.</p> <p>Thank you for your time and patience.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload