By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,965 Members | 1,702 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,965 IT Pros & Developers. It's quick & easy.

'no database selected'

P: 1
Hi there, I am getting a 'no database selected' error when I try to run a query on one of my pages.

if (!isset($_SESSION['wagentje'])) {
$_SESSION['wagentje']['artikels'] = array();

$id = $_GET['id'];

if ($_GET['action'] == 'add') {
if (isset($_GET['aantal'])) $aantal = $_GET['aantal']; else $aantal = 1;
if (!isset($_SESSION['wagentje']['artikels'][$id])) $_SESSION['wagentje']['artikels'][$id] = 0;
$_SESSION['wagentje']['artikels'][$id] += $aantal;
} else if ($_GET['action'] == 'delete') {
$link = new mysqli($dbserver, $user, $passwd, $dbnaam);
foreach($_SESSION['wagentje']['artikels'] as $artikel => $sleutel) {

echo "$artikel\n <br>";
echo mysql_result(mysql_query("SELECT thumbnail FROM hellinx_artikel WHERE artikelnr=\"$artikel\"") or die (mysql_error()));

$link->close() or die("Kan link met $dbserver niet sluiten.");


I am positive that the user has the right priviliges and that the file is correct ( since I use it on other pages and those work)

Thanks :)
Feb 9 '08 #1
Share this Question
Share on Google+
2 Replies

Expert 100+
P: 801
You need to use mysqli_query() instead of mysql_query().
Feb 9 '08 #2

Expert 2.5K+
P: 4,258
Since you use the oo style, you have to use it like
if ($link->query .....

Feb 10 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.