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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Connection problem?

Status
Not open for further replies.

SjrH

IS-IT--Management
Jun 24, 2003
747
GB
I know very little about sql so excuse me if this is a simple problem!

I'm getting the following error (multiple times in fact) -

Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource

I believe the settings in the PHP file are correct -

$cn=@mysql_connect("localhost","db_usr","password");
$db=@mysql_select_db("db_name",$cn);

The user account i'm using is the db owner.
I'm also using the MySQL administrator program to connect to the server, which will show me the db and tables etc...
but I can't connect to the user administration panel (access denied), could this be a permissions problem, or maybe something the hosting company is restricting?

Is there a command I can execute that will list the db_user's current permissions?

Thanks
 
If you are not running this code from the machine where the database lives, then localhost will not work. If that's the case, change localhost to the IP or name of the database server.

Mark

SELECT * FROM management WHERE clue > 1
> 0 rows returned

--ThinkGeek T-Shrit
 
Your database is externally hosted, but you're connecting to localhost? You need to use the server's IP address or hostname instead.

Also, I'm not a PHP user, but shouldn't you check the result of the connection attempt before trying to use it?

You can check global permissions with an SQL query:
[tt]
SELECT * FROM mysql.user WHERE user='db_usr'
[/tt]
There may also be database-level, table-level, and column-level permissions; these can be queried in the same way, using the mysql.db, mysql.tables_priv, mysql.columns_priv tables.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top