473,471 Members | 1,860 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

No database selected

I have identical names for the database, user and password on the local
machine and on the remote site. I also have identical tables and info in
the tables. It works perfectly on the local machine. On the remote site I
get "No Database Selected". It happens in the mysql_query call.

echo "ssLogin = " . $ssLogin . " ";
$LoginRS = mysql_query($LoginRS__query, $ssLogin) or die(mysql_error());
echo "LoginRS = " . $LoginRS;

This gives:
ssLogin = Resource id #3 No Database Selected

On both machines I have have a require file which is:

<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_ssLogin = "localhost";
$database_ssLogin = "the_database_name";
$username_ssLogin = "the_username";
$password_ssLogin = "the_password";
$ssLogin = mysql_pconnect($hostname_ssLogin, $username_ssLogin,
$password_ssLogin) or die(mysql_error());
?>

I thought it might be the $hostname_ssLogin, that it had to be something
else. However, if it is not localhost, then the mysql_pconnect fails.

Any ideas?

Shelly
Jul 17 '05 #1
7 9499
Shelly (sh*******@asap-consult.com) decided we needed to hear...
I have identical names for the database, user and password on the local
machine and on the remote site. I also have identical tables and info in
the tables. It works perfectly on the local machine. On the remote site I
get "No Database Selected". It happens in the mysql_query call.

echo "ssLogin = " . $ssLogin . " ";
$LoginRS = mysql_query($LoginRS__query, $ssLogin) or die(mysql_error());
echo "LoginRS = " . $LoginRS;

This gives:
ssLogin = Resource id #3 No Database Selected

On both machines I have have a require file which is:

<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_ssLogin = "localhost";
$database_ssLogin = "the_database_name";
$username_ssLogin = "the_username";
$password_ssLogin = "the_password";
$ssLogin = mysql_pconnect($hostname_ssLogin, $username_ssLogin,
$password_ssLogin) or die(mysql_error());
?>

I thought it might be the $hostname_ssLogin, that it had to be something
else. However, if it is not localhost, then the mysql_pconnect fails.

Any ideas?

Shelly

While your test machine may have only one (default) database, your
remote machine will probably require you to specify which db you
want to use... you can do this right after you connect with a call
such as
$status = mysql_select_db($database_ssLogin, $ssLogin);

As an aside, are you sure your webhost allows persistent connections?
I wouldn't have thought so, but a few might I suppose.

--
Dave <da**@REMOVEbundook.com>
(Remove REMOVE for email address)
Jul 17 '05 #2
"Dave" <da**@REMOVEbundook.com> wrote in message
news:7h************@fawlty.homelinux.net...
While your test machine may have only one (default) database, your
remote machine will probably require you to specify which db you
want to use... you can do this right after you connect with a call
such as
$status = mysql_select_db($database_ssLogin, $ssLogin);

As an aside, are you sure your webhost allows persistent connections?
I wouldn't have thought so, but a few might I suppose.
I had one already there:
mysql_select_db($database_ssLogin, $ssLogin);
$encryptedPassword = md5($_POST["password"]);
$LoginRS__query=sprintf("SELECT username, password, level, status
FROM ssusername WHERE username='%s' AND password='%s'",
get_magic_quotes_gpc() ? $loginUsername :
addslashes($loginUsername),
$encryptedPassword);
$LoginRS = mysql_query($LoginRS__query, $ssLogin) or die(mysql_error());

where it fails.

Here is a possiblity. Tell me what you think. On my local machine I am
running PHP5 but I think the server is running PHP4.x

Shelly


--
Dave <da**@REMOVEbundook.com>
(Remove REMOVE for email address)

Jul 17 '05 #3
Shelly (sh*******@asap-consult.com) decided we needed to hear...
"Dave" <da**@REMOVEbundook.com> wrote in message
news:7h************@fawlty.homelinux.net...
While your test machine may have only one (default) database, your
remote machine will probably require you to specify which db you
want to use... you can do this right after you connect with a call
such as
$status = mysql_select_db($database_ssLogin, $ssLogin);

As an aside, are you sure your webhost allows persistent connections?
I wouldn't have thought so, but a few might I suppose.


I had one already there:
mysql_select_db($database_ssLogin, $ssLogin);
$encryptedPassword = md5($_POST["password"]);
$LoginRS__query=sprintf("SELECT username, password, level, status
FROM ssusername WHERE username='%s' AND password='%s'",
get_magic_quotes_gpc() ? $loginUsername :
addslashes($loginUsername),
$encryptedPassword);
$LoginRS = mysql_query($LoginRS__query, $ssLogin) or die(mysql_error());

where it fails.

Here is a possiblity. Tell me what you think. On my local machine I am
running PHP5 but I think the server is running PHP4.x

Shelly

I wouldn't have thought PHP version should matter in this case - more
likely its a MySQL issue.

I would try checking the return value from mysql_select_db. If you get
false then that might indicate a permissions problem. e.g. with my host
when I create a MySQL user I then have to associate that user with any
database I want to use it with, as a seperate step - if thats not done
then even though I can connect fine, selecting a database will fail
until I associate the user...

--
Dave <da**@REMOVEbundook.com>
(Remove REMOVE for email address)
Jul 17 '05 #4
*** Shelly wrote/escribió (Sun, 22 May 2005 22:43:11 -0400):
mysql_select_db($database_ssLogin, $ssLogin);


No error checking here?

From manual:

usage:

bool mysql_select_db ( string database_name [, resource link_identifier ] )

Returns TRUE on success or FALSE on failure.
--
-- Álvaro G. Vicario - Burgos, Spain
-- http://bits.demogracia.com - Mi sitio sobre programación web
-- Don't e-mail me your questions, post them to the group
--
Jul 17 '05 #5

"Alvaro G Vicario" <al******************@telecomputeronline.com> wrote in
message news:19*****************************@40tude.net...
*** Shelly wrote/escribió (Sun, 22 May 2005 22:43:11 -0400):
mysql_select_db($database_ssLogin, $ssLogin);


No error checking here?

From manual:

usage:

bool mysql_select_db ( string database_name [, resource
link_identifier ] )


This the generated code from Dreamweaver. I'll add a check.

Shelly
Jul 17 '05 #6
> "Alvaro G Vicario" <al******************@telecomputeronline.com> wrote in
message news:19*****************************@40tude.net...
*** Shelly wrote/escribi? (Sun, 22 May 2005 22:43:11 -0400):
mysql_select_db($database_ssLogin, $ssLogin);


No error checking here?

From manual:

usage:

bool mysql_select_db ( string database_name [, resource
link_identifier ] )


This the generated code from Dreamweaver. I'll add a check.

Shelly


I added:

if (!mysql_select_db($database_ssLogin, $ssLogin)) {
echo "The mysql_select_db returned FALSE";
}

and it echoed. You are correct. It is failing in mysql_select_db. No what
do I do?

Shelly
Jul 17 '05 #7
Shelly wrote:
I added:

if (!mysql_select_db($database_ssLogin, $ssLogin)) {
echo "The mysql_select_db returned FALSE";
}

and it echoed. You are correct. It is failing in mysql_select_db. No what do I do?


Add:

echo mysql_error();

To find out what the problem is.

--
Oli

Jul 17 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
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: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.