Hi again!

If it would be so simple I would not ask...

OK, once more:
#!/usr/local/bin/php -q
<?php
$link1 = mysql_connect("localhost","user","passwd")
  || die ("Fehler! Zeile ".__LINE__.":\n".$php_errormsg."\n".mysql_error());
echo "Link 1: $link1\n";
if (mysql_select_db("test", $link1)) {
   echo "Successful select of test\n";
} else {
   echo "Failed to select test\n";
   die ("Fehler! Zeile ".__LINE__.":\n".mysql_error()."\n");
}
?>
gives this output:
Link1: 1
Warning: Supplied argument is not a valid MySQL-Link resource in
/home/bt/bin/test.php on line 5
Failed to select db
Fehler! Zeile 9:

And once again I describe it:
I've tested all settings for MySQL in the php.ini.




Jason Wong wrote:

> 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
> 


-- 
Berthold


-- 
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