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!

MySQL PHP error! Help!

Status
Not open for further replies.

James1981

Programmer
Nov 2, 2002
76
US
Hi,

I'm getting the following error when trying to query a table:

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

Any ideas?

Thanks in advance

James.
 
means you haven't set up your conection properly or you haven't chosen a database that exists or you don't have access etc etc etc ... use the function below to show details of mysql errors.
<?php
// your details

$host=2localhost&quot;; // normal default
$user=&quot;your_username&quot;;
$pass=&quot;your_password&quot;;
$database=&quot;your_database&quot;;

// database connect and select
// note: we hide the general spam using @ as we get detailed spam from the function
$connection=@mysql_connect($host.$user,$pass);
mysql_checkerror();
@mysql_select_db($database,$connection);
mysql_checkerror();

//ALL your stuff in here
stuff
//end your stuff

// functions
// check mysql errors and print them out meaningfully
function mysql_checkerror(){

$err_no=mysql_errno();

if ($err_no > 0 ){

echo &quot;<h2> Error:</h1> &quot; . mysql_errno() . &quot;: &quot; . mysql_error() . &quot;<br>\n&quot;;

exit;

}
}
?>
______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
Cool, thanks for that - i sorted out the problem!

Many thanks

James
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top