473,473 Members | 2,134 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

'no database selected'

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

[PHP]<?php
session_start();
require('safe/fhlogin.inc.php');
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') {
unset($_SESSION['wagentje']['artikels'][$id]);
}
?>
<html>
<head>
</head>
<body>
<?php
$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.");

?>
</body>
</html>[/PHP]

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

Thanks :)
Feb 9 '08 #1
2 1820
mwasif
802 Recognized Expert Contributor
You need to use mysqli_query() instead of mysql_query().
Feb 9 '08 #2
ronverdonk
4,258 Recognized Expert Specialist
Since you use the oo style, you have to use it like
[php]
if ($link->query .....
[/php]

Ronald
Feb 10 '08 #3

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

Similar topics

5
by: Coz | last post by:
Hi all, I'm looking for help again!!! I have been writing a page to update a database but now have another 'silly' problem with listbox's...Grrr... I'm trying to populate the list box with...
10
by: Mamuninfo | last post by:
Hello, Have any function in the DB2 database that can generate unique id for each string like oracle, mysql,sybase,sqlserver database. In mysql:- select md5(concat_ws("Row name")) from...
7
by: vsiat | last post by:
I am trying to create a treeview out of a database table with the typical structure ID, NAME, PARENTID, TYPE, EXTRA_INFO, where is linked to the . What I want to achieve is create a tree made...
1
by: jwright1 | last post by:
I am trying to set the selected value of a radio button list from a value stored in a table of a database. using vb codebehind asp.net. I tried binding the selected index item and selected index...
14
by: John Salerno | last post by:
Since the connect method of mysqldb requires a database name, it seems like you can't use it without having a database already created. So is there a way to connect to your mysql server (without a...
1
by: ghadley_00 | last post by:
Hi, I have a php form that encodes the responses to various <Select> field drop down menus as numbers (e.g. 0 to 50), and then posts the data to a MySQL table. I am trying to implement a form...
0
by: DxB | last post by:
Hello All i'm newbie here, was googling and found this site, it looks nice and i think i can learn a lot here, i have ms sql 2000 with 40 database and static public ip address. i am accessing...
10
by: patsman77 | last post by:
I hope this is the right spot to post this.... I am working on a form to pull the information from the database. I am trying to use arrays, but I only get one record to come back and it is...
1
suriacute85
by: suriacute85 | last post by:
Hi, I'm very new in web programming. i have afew question here. 1. i have a table which have a data, in 3 lines. now i want to save the data in the 3 lines into the database access. can i do that?...
4
by: sialater | last post by:
Hello, I realise there are a lot of topics related to this problem but many of what I have found has run cold or unresolved. What I have is an addressbook clone where there are groups which have...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.