hoppyite Posted July 17, 2007 Share Posted July 17, 2007 Hi all, I have a function to connect to mysql which can be called several times during the running of a script: function ConnectToDb($server, $user, $pass, $database) { $s = mysql_connect($server, $user, $pass); //or die ( "<H3>Server unreachable</H3>"); $d = mysql_select_db($database, $s); if(!$s || !$d) return false; else return true; } The function and script works fine. But if I remove the comments so that the mysql_connect reads: $s = mysql_connect($server, $user, $pass) or die ( "<H3>Server unreachable</H3>"); Then the first attempt to connect works fine but a second attempt to connect fails and the script dies here. Does anyone know why this happens? Thanks in advance. John Quote Link to comment Share on other sites More sharing options...
trq Posted July 17, 2007 Share Posted July 17, 2007 Try... $s = mysql_connect($server, $user, $pass) or die (mysql_error()); And lets see what the error is. Quote Link to comment Share on other sites More sharing options...
hoppyite Posted July 17, 2007 Author Share Posted July 17, 2007 Hi Thorpe, Thank you for replying. I tried to find out the error as suggested but nothing is returned from mysql_error(). John PS: sorry mean't to add that as soon as the 'or die' is included the script does just that. So I don't think it even gets as far as evaluating my_sql_error()! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.