473,387 Members | 1,904 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,387 software developers and data experts.

No luck making a databast connection

I've included db.php into my script, and this is all it contains:

$host = 'localhost';
$username = '***';
$password = '***';
$database = '***';
$connection = mysql_pconnect($host, $username, $password);
$mysql_select_db($database, $connection);

obviously with the other fields filled out.

My webhost tells me to use this script:

$dbh=mysql_connect ("localhost", "<USERNAME HERE>", "<PASSWORD HERE>") or
die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("<TABLE NAME>");

neither one of these methods work, actually - I get this error:
[the contents of my db.php file here, in plain text!]No Database Selected

Anyone know what I'm doing wrong?
Jul 17 '05 #1
5 3765

$dbh=mysql_connect ("localhost", "<USERNAME HERE>", "<PASSWORD HERE>") or
die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("<TABLE NAME>"); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^???
should be:
mysql_select_db($database);
neither one of these methods work, actually - I get this error:
[the contents of my db.php file here, in plain text!]No Database Selected

Anyone know what I'm doing wrong?

Good luck this time!
Wangs
Jul 17 '05 #2
"Taliesson Wang" <wa****@163.net.no.spam> wrote in message
news:bo***********@news.wplus.net...

$dbh=mysql_connect ("localhost", "<USERNAME HERE>", "<PASSWORD HERE>") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("<TABLE NAME>");

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^???
should be:
mysql_select_db($database);

neither one of these methods work, actually - I get this error:
[the contents of my db.php file here, in plain text!]No Database Selected
Anyone know what I'm doing wrong?

Good luck this time!
Wangs


That's what I've been doing

doesn't work!
Jul 17 '05 #3

"Taliesson Wang" <wa****@163.net.no.spam> wrote in message
news:bo***********@news.wplus.net...

$dbh=mysql_connect ("localhost", "<USERNAME HERE>", "<PASSWORD HERE>") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("<TABLE NAME>");

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^???
should be:
mysql_select_db($database);

neither one of these methods work, actually - I get this error:
[the contents of my db.php file here, in plain text!]No Database Selected
Anyone know what I'm doing wrong?

Good luck this time!
Wangs


This is what i have, the database is empty, and it's just a testing server
anyway, so you can have the username+password:

$host = 'localhost';
$username = 'yem_dbtest';
$password = 'dbpass';
$database = 'yem_testdb';

$connection = mysql_connect($host, $username, $password);

//$mysql_select_db($database, $connection);
mysql_select_db($database);

Not working!!!
This is what I have on my IE:

$host = 'localhost'; $username = 'yem_dbtest'; $password = 'dbpass';
$database = 'yem_testdb'; $connection = mysql_connect($host, $username,
$password); //$mysql_select_db($database, $connection);
mysql_select_db($database); No Database Selected
Jul 17 '05 #4
> Not working!!!
This is what I have on my IE:

$host = 'localhost'; $username = 'yem_dbtest'; $password = 'dbpass';
$database = 'yem_testdb'; $connection = mysql_connect($host, $username,
$password); //$mysql_select_db($database, $connection);
mysql_select_db($database); No Database Selected


If *this* really is what your IE comes up with, than it's just that the
page doesn't get parsed with PHP! Cause it's showing it as plain text.
Is it a *.php file? And do other *.php files work for instance with only
<?php phpinfo(); ?>

stevijn
// @
// drbobco
// .com
Jul 17 '05 #5
>
$host = 'localhost'; $username = 'yem_dbtest'; $password = 'dbpass';
$database = 'yem_testdb'; $connection = mysql_connect($host, $username,
$password); //$mysql_select_db($database, $connection);
mysql_select_db($database); No Database Selected

seems that your php engine not work.
check the doc type, maybe should be .php not .php3.

T.Wang
Jul 17 '05 #6

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

Similar topics

4
by: Fuzzyman | last post by:
In a nutshell - the question I'm asking is, how do I make a socket conenction go via a proxy server ? All our internet traffic has to go through a proxy-server at location 'dav-serv:8080' and I...
6
by: David Rasmussen | last post by:
I use urllib2 to do some simple HTTP communication with a web server. In one "session", I do maybe 10-15 requests. It seems that urllib2 opens op a connection every time I do a request. Can I...
2
by: lucifer | last post by:
hi i am making an http server it has following functions main() { if option is "-?", output the hints and stop check the directory supplied is sensible and not a security risk become a daemon...
2
by: Øyvind Isaksen | last post by:
In asp 3.0 I used an procedure (that I included) to save and update articles, like this: <% Sub ConnObj(SQL) set cn = server.CreateObject("ADODB.Connection") cn.Open ConnString cn.Execute SQL...
18
by: dbahooker | last post by:
team i'm having a tough time getting these data readers to work correctly I'd just like to be able to centralize my GetDataReader functions; so i can pass a simple SQL statement and be passed...
35
by: Terry Jolly | last post by:
Web Solution Goal: Have a global database connection Why: (There will be 30+ tables, represented by 30+ classes) I only want to reference the database connection once. I put the connection...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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,...

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.