Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cannot select db

Status
Not open for further replies.

squarkman

Technical User
Mar 10, 2008
34
Hi Gurus,
I have a php opt-in system works perfectly. Next, I simply removed the one line that mailed the information to my email address and replaced it with the code below to get one step closer to adding data to my database thru the system after confirmation. I get an error. The only thing that could be wrong is in the code below. The name of the database is correct, the username and password are correct and I guess 'localhost' works since the error I get is "cannot select db".
-----------------------

$host="localhost";
$username="xxxxxx";
$password="xxxxxx";
$db_name="xxxxxxxxx";
mysql_connect("$host", "$username", "$password");
mysql_select_db("$db_name")or die("cannot select db");
mysql_query("INSERT INTO customer (name, sex)VALUES ('Robert','male')");
mysql_query("INSERT INTO customer (name, sex)VALUES ('Sally','Female')");
mysql_close($con);
 
FINALLY IT WORKS!
Apparently you have to use the Control Panel user and psw to connect. I guess the database Administrator user and psw are exactly the same and cannot be changed.
I don't see why they give you the option of adding a user when the user will never be able to connect without the Databasse Administrator user and pswd.
Maybe added users can only access the db thru the control panel only with their user and pswd.
Quite confusing. Wish someone had mentioned all this in the control panel.
Thanks to all for bearing with me in this.
Rocky
 
Glad you got it working.

----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top