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

Mysql connection problem

Status
Not open for further replies.

SjrH

IS-IT--Management
Jun 24, 2003
747
GB
I'm getting an error when trying to connect a php page to a mysql database -

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

The php code is -

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

Is this likely to be a connection problem, or a problem with mysql?

Apologies but I know very little about php or mysql!

Thanks
 
try changing these lines
Code:
$cn=@mysql_connect("xxx.xxx.xxx.xxx","db_usr","password");
$db=@mysql_select_db("db_name",$cn);
to
Code:
@mysql_connect("xxx.xxx.xxx.xxx","db_usr","password") or die("can't connect to db server: " . mysql_error());
@mysql_select_db("db_name") or die("can't connect to database: " . mysql_error());

this will give you some feedback on the error. for the query, don't reference the connection at the moment. just
Code:
$result = mysql_query("Select * from table");
[/code]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top