473,320 Members | 1,872 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

mysql_select_db doesn't work

Hello,
I'm trying to connect a DB but I can't. Can anybody help me?
Here is the piece of code...

<?php
$verbindung = mysql_connect("localhost", "coasters", "");
if (!$verbindung) {
die('Not connected : ' . mysql_error());
}
// make coaster the current db
$db_selected = mysql_select_db('coaster', $verbindung);
if (!$db_selected) {
die ('Can\'t use coaster : ' . mysql_error());
}
?>

I get the following message:
Can't use coaster : Access denied for user ''@'localhost' to database
'coaster'

The connection to the server seems to work.
I have installed WAMPP2 and I use Macromedia Dreamweaver. I save the
file as PHP and I send it to my webserver. The DB is local under
MySQL\data. Do I have to send the DB to the server where I test, too?

Thanks

Jul 17 '05 #1
7 2823
be*****@coaster.ch wrote:
Hello,
I'm trying to connect a DB but I can't. Can anybody help me?
Here is the piece of code... <?php
$verbindung = mysql_connect("localhost", "coasters", "");
if (!$verbindung) {
die('Not connected : ' . mysql_error());
}
// make coaster the current db
$db_selected = mysql_select_db('coaster', $verbindung);
if (!$db_selected) {
die ('Can\'t use coaster : ' . mysql_error());
}
?> I get the following message:
Can't use coaster : Access denied for user ''@'localhost' to database
'coaster' The connection to the server seems to work.
I have installed WAMPP2 and I use Macromedia Dreamweaver. I save the
file as PHP and I send it to my webserver. The DB is local under
MySQL\data. Do I have to send the DB to the server where I test, too? Thanks


Specify a user that has access to coaster from localhost.

--
Jim Pennino

Remove .spam.sux to reply.
Jul 17 '05 #2
Hi Jim,
In PHPMyAdmin I've just defined the following:
In DB webauth:
user: bett
password: sapto
In DB mysql Table DB: a new entry for DB coaster with user bett
In DB mysql Table User: a new entry for user bett

Now the code:
?php
$db_server = "localhost";

/* Datenbankname */
$db_name = "coaster";

/* Datenbankuser */
$db_user = "bett";

/* Datenbankpasswort */
$db_passwort = "sapto";

/* Erstellt Connect zu Datenbank her */
$db = @MYSQL_PCONNECT($db_server,$db_user,$db_passwort)
or die ("Konnte keine Verbindung zur Datenbank herstellen");
$db_select = @MYSQL_SELECT_DB($db_name);
if($db_select)
echo "Datenbank wurde ausgewählt";
?>

the DB is local, but I've sent the php document to my webserver. Is it
correct? because I cannot see it local...

and I received the following:
Konnte keine Verbindung zur Datenbank herstellen

What can I do????

Jul 17 '05 #3
be*****@coaster.ch wrote:
Hi Jim,
In PHPMyAdmin I've just defined the following:
In DB webauth:
user: bett
password: sapto
In DB mysql Table DB: a new entry for DB coaster with user bett
In DB mysql Table User: a new entry for user bett

Now the code:
?php
$db_server = "localhost";

/* Datenbankname */
$db_name = "coaster";

/* Datenbankuser */
$db_user = "bett";

/* Datenbankpasswort */
$db_passwort = "sapto";

/* Erstellt Connect zu Datenbank her */
$db = @MYSQL_PCONNECT($db_server,$db_user,$db_passwort)
or die ("Konnte keine Verbindung zur Datenbank herstellen");
$db_select = @MYSQL_SELECT_DB($db_name);
if($db_select)
echo "Datenbank wurde ausgewählt";
?>

the DB is local, but I've sent the php document to my webserver. Is it
correct? because I cannot see it local...

and I received the following:
Konnte keine Verbindung zur Datenbank herstellen

What can I do????


Are you saying the database is on your local machine but you're php page
is on the server?

If so, that won't work. PHP runs on the server, and in your PHP code
"localhost" therefore refers to the server - not your local machine.

Create the database on the server and ensure you have the correct
permissions set.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jul 17 '05 #4
The DB is unter MySql/Data on my local server and I send the php doc to
my webserver to test. How can I test local? Where should I save the php
doc?

Jul 17 '05 #5
be*****@coaster.ch wrote:
The DB is unter MySql/Data on my local server and I send the php doc
to my webserver to test. How can I test local? Where should I save
the php doc?


If you're using "localhost" as the database host name, then the PHP script
and the database will have to be on the same machine.

--
Tony Garcia
Web Right! Development
to*****@webrightdevelopment.SPAM.com
Jul 17 '05 #6
be*****@coaster.ch wrote:
The DB is unter MySql/Data on my local server and I send the php doc to
my webserver to test. How can I test local? Where should I save the php
doc?


You need to run the php script on the machine on which the database
resides. This means either creating the database on your server, or
installing a web server on your system to test.

"localhost" always refers to the machine on which the script or program
is running. Since PHP runs on the server, it refers to the server.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jul 17 '05 #7
what was installed really with wampp2? On Services I can see Apache,
MySql (is this MySql Server?). Do I have to install something else? I
have the feeling I need something else... I created a user and password
in PHPMyAdmin for the different DBs... is that enough? How should I
installed aweb server on my system?

Jul 17 '05 #8

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

Similar topics

3
by: Oliv | last post by:
Bonjour, Est-il possible de se passer de l'instruction mysql_select_db() afin de sélectionner une base de données par défaut dans MySQL ? Je pense en particulier à l'association d'une base par...
7
by: AnnMarie | last post by:
My JavaScript Form Validation doesn't work at all in Netscape, but it works fine in IE. I made some of the suggested changes which enabled it to work in IE. I couldn't make all the changes...
39
by: Mark Johnson | last post by:
It doesn't seem possible. But would the following also seem a violation of the general notions behind css? You have a DIV, say asociated with class, 'topdiv'. Inside of that you have an anchor...
149
by: Christopher Benson-Manica | last post by:
(Followups set to comp.std.c. Apologies if the crosspost is unwelcome.) strchr() is to strrchr() as strstr() is to strrstr(), but strrstr() isn't part of the standard. Why not? --...
6
by: A.M-SG | last post by:
Hi, I have an aspx page at the web server that provides PDF documents for smart client applications. Here is the code in aspx page that defines content type: Response.ContentType =...
4
by: bbp | last post by:
Hello, In an ASPX page I have a "Quit" button which make a simple redirect in code-behind. This button doesn't work no more since (I think) I moved from the framework 1.0 to 1.1 and it doesn't...
10
by: Sourcerer | last post by:
I wrote this very simple code in .NET VC++. I compiled it on my system, and tried to run it on my friend's computer (he doesn't have the compiler). We both have Windows XP Professional. I have .NET...
39
by: alex | last post by:
I've converted a latin1 database I have to utf8. The process has been: # mysqldump -u root -p --default-character-set=latin1 -c --insert-ignore --skip-set-charset mydb mydb.sql # iconv -f...
1
by: wizardry | last post by:
hello - I'm inserting the records one after another into a seperate table. and it just errors says: warning: mysql_select_db(): supplied argument is not a valid mysql-link resource heres...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.