|
| Register now to interact with over 11,000 members! Registered users have Posting Privileges, free access to Private Messaging, Email Notifications and more. |
|
|||||||
![]() |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
Registered
Join Date: Dec 2004
Location: Canada
Posts: 12
Reputation: 5
|
I can not access my database using a script on my website
If just starting using PHP and MySQL and I am starting to understand how it works, I just have one problem. When I tried to run a script to access the stuff in the database, It will not do it. I can go into phpMyAdmin and do all sorts of stuff with the database, but I can not access it when i try some php on my site. The following is an example of what i am using:
include("dbinfo.php"); mysql_connect(localhost, $username, $password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM contacts"; $result=mysql_query($query); dbinfo.php is where I am storing the username and password info. Each time i run the script. i get the die result "Unable to select database" I am thinkning it is something simple, but I am stumped, any suggestions Johnny O |
|
|
|
|
#2 |
|
Posts: n/a
|
okay.. i think its that your mysql connect with the whole localhost, username and password isnt filled in right.. i'm prob wrong, but heres what I've used in the past (not with powweb yet)
(since my sites still being set up) - (the parts such as database, password and username are what you fill in) * Connect to the mysql database. */ $conn = mysql_connect("localhost", "database_username ", password ) or die(mysql_error()); mysql_select_db('database_username', $conn) or die(mysql_error()); GLOBAL $conn; ----- the original php code that was written for me was: * Connect to the mysql database. */ $conn = mysql_connect("localhost", "da_cleako", "cleako") or die(mysql_error()); mysql_select_db('da_cleako', $conn) or die(mysql_error()); GLOBAL $conn; |
|
|
#3 |
|
Posts: n/a
|
now that code never worked for me when i tried with fortune city.. but their mysql never worked.. and fortune city is the number 1 worse ever host.. so as soon as my domain is transfered from them to here, i'll know if the code works here.. (along with setting up a database here)
|
|
|
#4 |
|
Registered
Join Date: Dec 2004
Location: Canada
Posts: 12
Reputation: 5
|
Thanks, but that didn't help. I've tried everything i could find, different variations on how to write the code, but nothing is working. I'm just trying to make a page that will let me access the info in the database, but I haven't figured out how yet.
|
|
|
|
|
#5 | |
|
Join Date: Nov 2002
Location: Solomons Island
Posts: 2,217
Reputation: 212
|
Quote:
__________________
-bruce /* somdcomputerguy */ 'If you change the way you look at things, the things you look at change.' |
|
|
|
|
|
#6 |
|
Posts: n/a
|
yeah.. I was thinking about that as an issue.. but I didnt know about the numbering.. or ip adress to place there for powweb
|
|
|
#7 |
|
Posts: n/a
|
- i'll have to figure that out when I need to activate my database php file..
|
|
|
#8 |
|
Join Date: Nov 2002
Location: Solomons Island
Posts: 2,217
Reputation: 212
|
When a db is activated in OPS, you'll be told what address the db has.
__________________
-bruce /* somdcomputerguy */ 'If you change the way you look at things, the things you look at change.' |
|
|
|
|
#9 |
|
Posts: n/a
|
got it setup now.
|
|
|
#10 |
|
Registered
Join Date: Dec 2004
Location: Canada
Posts: 12
Reputation: 5
|
Yes, that's was it!! Thanks a bunch snowmaker.
Johnny O |
|
|
|
|
#11 |
|
Join Date: Nov 2002
Location: Solomons Island
Posts: 2,217
Reputation: 212
|
You bet. Glad you got it.
__________________
-bruce /* somdcomputerguy */ 'If you change the way you look at things, the things you look at change.' |
|
|
![]() |
| Thread Tools | Search this Thread |
|
|