On Friday 01 February 2002 15:38, Berthold wrote:
> Hi!
>
> Thank you.
> But I cannot use that $link1 and/or $link2 to select two databases on
> different servers...
> If I use $link1 the first time to select the first database on the first
> server I got that error. But without that $link1-variable AND only one
> connection in the script it works.
>
> And it makes no sense if I use it as shell-prog or with Apache-Builtin-PHP.
>
> eg:
> #!/usr/local/bin/php -q
> <?php
> $link1 = mysql_connect("localhost","a");
> echo 'Link 1: '.$link1 .'<BR>';
> if (mysql_select_db("test", $link1)) {
>       echo 'Successful select of test<BR>';
> } else {
>       echo 'Failed to select test<BR>';
> }
> ?>
> gives this output:
> Warning: Supplied argument is not a valid MySQL-Link resource in
> /home/bt/bin/test.php on line 4

Try:

 $link1 = mysql_connect("localhost","a") or die ("Cannot connect to db!"); 

If it dies, then you know you have a problem connecting to the db.

If you follow the examples in the code with regards to the DB functions they 
all have a die() statement on the end for debugging purposes. It's there to 
help you.

In this case your real problem is most likely that you're not giving the 
correct number of parameters to mysql_connect($host, $user, $password).

Again, proper use of die() would have quickly helped you track down where the 
real problem was. Instead of trying to figure out what is wrong with line 4!

hth
-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk

/*
Congratulations!  You are the one-millionth user to log into our system.
If there's anything special we can do for you, anything at all, don't
hesitate to ask!
*/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to