Koozali.org: home of the SME Server

SELECT or DIE("Unable to select database'")

Mal

SELECT or DIE("Unable to select database'")
« on: May 19, 2003, 03:01:36 AM »
Hello Forum,

If the SELECT command fails I would like to link to a webpage rather than just have a blank screen with "Unable to select database"

I cannot find anything in the manual to help me here and I have tried various guesses putting the url in the brackets (don't laugh!).

Any ideas?

Thanks in advance,


Mal.

Nathan Fowler

Re: SELECT or DIE("Unable to select database'")
« Reply #1 on: May 21, 2003, 11:42:35 PM »
What language, your provided almost no details in your question?  I'm going to assume PHP.

$db = mysql_connect("localhost", "mysql_user", "mysql_password");
$result = mysql_query($db,"SELECT * FROM MY TABLE ORDER BY MYVALUE;");

if($result){
  //Do your record enumeration or code here.
}else{
  echo ("Select failed\n");
  //Do select failed code here
}


Not to be a butt, but RTFM:  http://www.php.net/manual/en/function.mysql-db-query.php