Hi,

Thursday, April 15, 2004, 2:57:48 PM, you wrote:
>>How many versions of the wheel exist in the world >today? ...not many
>>hacked out of stone I bet :-)
>>
>>--
>>regards,
>>Tom

AB> what does that mean?? is everybody saying i should give up on this idea
AB> then??

What I am saying is that it doesn't matter what already exists if you
want to do it your way go ahead and give it a go.
On the original subject, if this is part of a class then I would set a
class variable called $last_error. Set this to '' at the begining of
your function and if there is an error then fill it with mysql info
with  in this case "Connection failed" or with other functions mysql_error();
That way if your function returns false you can do a call to your
class->get_last_error();

The other thing I find useful is to pass the line info to the
function so the error can have more meaning. A bit like this
(untested):

function Connect($host, $mysqluser, $mysqlpwd, $line=false){
  $this->last error = '';
  $link=mysql_connect($host, $mysqluser, $mysqlpwd)
  if(!$link){
    $this->last error = "Connection failed using $mysqluser on $host";
    if($line) $this->last error .= " on line:$line";
    return false;
  }
  else { return $link; }
}
function get_last_error(){
 return $this->last_error;
}

Then call it with
if($hndl = $class->Connect($host,$mysqluser,$mysqlpwd,__LINE__)){
  echo 'Connected <br>';
}else{
  echo '<font color="red">'.$class->get_last_error().'</font><br>'
}
-- 
regards,
Tom

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to