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

About Inserting values in the MYSQL database

P: n/a
I am not beginer of this language. I've worked on this language for 2
or 3 months.But now i have a problem to inserting values in the
database.It gives me error that DATABASE NOT SELECTED.
I am using wampserver.Please help me for this prob.
Aug 22 '08 #1
Share this Question
Share on Google+
9 Replies


P: n/a
>I am not beginer of this language. I've worked on this language for 2
>or 3 months.But now i have a problem to inserting values in the
database.It gives me error that DATABASE NOT SELECTED.
I am using wampserver.Please help me for this prob.
Then select a database.

Do one of the following:

(1) specify a database when using mysql_real_connect().
(2) use mysql_select_db() after mysql_connect(). And it would be a
good idea to check if it worked correctly before proceeding.

Remember, you need to use a VALID database name, one you have privileges
to access.
Aug 22 '08 #2

P: n/a
Bunty <bu************@gmail.comwrote:
>
I am not beginer of this language. I've worked on this language for 2
or 3 months.But now i have a problem to inserting values in the
database.It gives me error that DATABASE NOT SELECTED.
I am using wampserver.Please help me for this prob.
Connecting to a MySQL database in PHP requires two steps: one to connect to
the server (mysql_connect), and one to select a database (mysql_select_db).
This is different from many other language/database bindings, where the
connection string specifies the initial database.

My guess is that you forgot mysql_select_db.
--
Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Aug 22 '08 #3

P: n/a
On 22 Aug, 07:23, Tim Roberts <t...@probo.comwrote:
Bunty <bunty.virad...@gmail.comwrote:
I am not beginer of this language. I've worked on this language for 2
or 3 months.But now i have a problem to inserting values in the
database.It gives me error that DATABASE NOT SELECTED.
I am using wampserver.Please help me for this prob.

Connecting to a MySQL database in PHP requires two steps: one to connect to
the server (mysql_connect), and one to select a database (mysql_select_db).
This is different from many other language/database bindings, where the
connection string specifies the initial database.

My guess is that you forgot mysql_select_db.
--
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.
Actually, using mysql_select_db() or mysql_query("use $db") can make
life very complicated if you ever have to develop an application
spanning more than one database.

I've got into the habit of qualifying table names instead, e.g.

SELECT app.* FROM my_db.app, mysql.user
WHERE user.user=app.user

C.
Aug 22 '08 #4

P: n/a
C. (http://symcbean.blogspot.com/) wrote:
On 22 Aug, 07:23, Tim Roberts <t...@probo.comwrote:
>Bunty <bunty.virad...@gmail.comwrote:
>>I am not beginer of this language. I've worked on this language for 2
or 3 months.But now i have a problem to inserting values in the
database.It gives me error that DATABASE NOT SELECTED.
I am using wampserver.Please help me for this prob.
Connecting to a MySQL database in PHP requires two steps: one to connect to
the server (mysql_connect), and one to select a database (mysql_select_db).
This is different from many other language/database bindings, where the
connection string specifies the initial database.

My guess is that you forgot mysql_select_db.
--
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

Actually, using mysql_select_db() or mysql_query("use $db") can make
life very complicated if you ever have to develop an application
spanning more than one database.

I've got into the habit of qualifying table names instead, e.g.

SELECT app.* FROM my_db.app, mysql.user
WHERE user.user=app.user

C.
Which can still be done, even if you use mysql_select_db().

However, if you find you are often spanning databases in your apps, you
have a major database design problem.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Aug 22 '08 #5

P: n/a
ally wrote:
On Fri, 22 Aug 2008 08:46:44 -0400, Jerry Stuckle <js*******@attglobal.net>
wrote:
>However, if you find you are often spanning databases in your apps, you
have a major database design problem.

--

erm why?

Databases are meant to keep all the information together in one set of
tables. Spreading it out over multiple databases loses that concept.

And while MySQL's "databases" are closer to "schemas" in other
databases, the concept holds true there, also.

It's also a lot easier to backup a single database, and even easier to
change between a development and a production database - just change the
name in one global variable.

But this is getting off topic for a php newsgroup. More info can be
found in a database-related newsgroup.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Aug 22 '08 #6

P: n/a
Bunty ha scritto:
I am not beginer of this language. I've worked on this language for 2
or 3 months.But now i have a problem to inserting values in the
database.It gives me error that DATABASE NOT SELECTED.
I am using wampserver.Please help me for this prob.

please read OFFICIAL manual and use "copy and paste"
_all example works_

http://www.php.net/manual/en/
http://it.php.net/manual/en/function...-select-db.php

Aug 22 '08 #7

P: n/a
ally wrote:
On Fri, 22 Aug 2008 08:46:44 -0400, Jerry Stuckle <js*******@attglobal.net>
wrote:
>However, if you find you are often spanning databases in your apps, you
have a major database design problem.

--

erm why?
Cos jerry says so.

He obviously hasn't had to do what a certain person of my acquaintance
does for a living..interrogate multiple criminal databases across
several police forces and present an integrated view on data to the
detectives...IIRC he does indeed use php as well.
Aug 24 '08 #8

P: n/a
The Natural Philosopher wrote:
ally wrote:
>On Fri, 22 Aug 2008 08:46:44 -0400, Jerry Stuckle
<js*******@attglobal.net>
wrote:
>>However, if you find you are often spanning databases in your apps,
you have a major database design problem.

--

erm why?
Cos jerry says so.

He obviously hasn't had to do what a certain person of my acquaintance
does for a living..interrogate multiple criminal databases across
several police forces and present an integrated view on data to the
detectives...IIRC he does indeed use php as well.
Ambiguity on the word "database" here, I rather fancy.
--
John W. Kennedy
"The bright critics assembled in this volume will doubtless show, in
their sophisticated and ingenious new ways, that, just as /Pooh/ is
suffused with humanism, our humanism itself, at this late date, has
become full of /Pooh./"
-- Frederick Crews. "Postmodern Pooh", Preface
Aug 24 '08 #9

P: n/a
sool wrote:
On Fri, 22 Aug 2008 13:44:34 -0400, Jerry Stuckle <js*******@attglobal.net>
wrote:
>ally wrote:
>>On Fri, 22 Aug 2008 08:46:44 -0400, Jerry Stuckle <js*******@attglobal.net>
wrote:

However, if you find you are often spanning databases in your apps, you
have a major database design problem.

--
erm why?

Databases are meant to keep all the information together in one set of
tables. Spreading it out over multiple databases loses that concept.

And while MySQL's "databases" are closer to "schemas" in other
databases, the concept holds true there, also.

It's also a lot easier to backup a single database, and even easier to
change between a development and a production database - just change the
name in one global variable.

Clearly you are not conversant with how many real world situations operate.
Multiple database access is essential. Perhaps less time spent dealing with
small WWW site applications and more with the more professional and larger
situations would help you understand why that is approaching a "daft" response.

sool
-----------------------


I am VERY conversant with how real world situations operate - I've been
programming for over 40 years (including 13 years with IBM on large
mainframes), and an independent consultant for the last 18. My
experience predates the web by almost 25 years, and some of the
databases I've worked on are larger than anyone here has probably ever seen.

I started designing SQL databases back in the mid 80's - almost 25 years
ago. I have designed some databases larger than you would ever dream.
Of course, this has been on mainframes, not PC's.

But it's also clear from your response you have no real idea about how
to design a database correctly. You've probably never worked with
anything outside of PC's, MySQL and PHP. And you have no idea what
you're talking about.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Sep 2 '08 #10

This discussion thread is closed

Replies have been disabled for this discussion.