I have just uploaded my website to meebox (webhotel), where I have a mysql database through phpmyadmin. The database connection file is working. There is a connection but I get NO data from the database which I have stored.
Here is my php script, where I want to get some data.
The script worked on my localhost server. But I just can't find the error. Is the script too old?
<?php
$q = "SELECT * FROM journals ORDER BY timestamp DESC";
$r = mysqli_query($dbc, $q);
while($journal_list = mysqli_fetch_assoc($r)) { ?>
<div class="col-md-6 journal-list">
<a href="journalview.php?id=<?php echo $journal_list['id']; ?>">
<img class="journal-list-img" src="<?php echo $journal_list['image']; ´?>">
</a>
</div>
<?php } ?>
You are missing the 4th parameter, DB.
Just set a variable $db
with the desired DB and try it like this:
$servername = "localhost";
$username = "xxxx";
$password = "xxxx";
$db = "database_to_use";
$dbc = mysqli_connect($servername, $username, $password, $db)
if ($dbc->connect_errno) {
exit($dbc->connect_error);
}
unlike the old mysql_ extension where we had to do
mysql_select_db(...)
it can now be done within one line.