Re: [PHP] Re: [PHP General] RE: Problems with MySQL-Link [3:14370:14592]
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 testBR'; } else { echo 'Failed to select testBR'; } ? 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]
Re: [PHP] Re: [PHP General] RE: Problems with MySQL-Link [3:14370:14592]
On Friday 01 February 2002 16:23, Berthold wrote: Hi again! If it would be so simple I would not ask... OK, once more: #!/usr/local/bin/php -q 1) Has the mysql functions ever worked for you on that system? 2) Are you only get this problem when using php from the command line? -- Jason Wong - Gremlins Associates - www.gremlins.com.hk /* Give me enough medals, and I'll win any war. -- Napoleon */ -- 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]
Re: [PHP] Re: [PHP General] RE: Problems with MySQL-Link [3:14370:14592]
Hi! 1) Yes of course. I only have to delete the $link-variables... But then - of course - I can only use the last connection. 2) It made no sense. Shell or Apache. And the settings in php.ini are '-1' for 'unlimited'. And I use the right php.ini, even with the shell-version. Jason Wong wrote: On Friday 01 February 2002 16:23, Berthold wrote: Hi again! If it would be so simple I would not ask... OK, once more: #!/usr/local/bin/php -q 1) Has the mysql functions ever worked for you on that system? 2) Are you only get this problem when using php from the command line? -- 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]
Re: [PHP] Re: [PHP General] RE: Problems with MySQL-Link [3:14370:14592]
Hi! mysql_error returns nothing... The error arrives while selecting the database via: $link = mysql_connect(host,user,passwd); mysql_select_db(bla, $link); echo $link returns always '1'! David Robley wrote: In article [EMAIL PROTECTED], [EMAIL PROTECTED] says... So, I've testet all possible I found in my brain... CGI or Apache module: same error mysql_connect or mysql_pconnect: same error Variing settings in php.ini: same error How can I solve that problem? BTW: Here I describe it again: Connecting to a database works well: ok Working with that database: ok Using the additional $link-Parameter: false Not a valid resource id ... And it does not matter how many different links with different servers I use! The resource-id is always '1'. Strange... Not a valid resource ID usually means a problem with the query - in fact this might be in the FAQ. Use mysql_error() after the database query to see if mysql returns a useful error. -- 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]
Re: [PHP] Re: [PHP General] RE: Problems with MySQL-Link [3:14370:14592]
In article [EMAIL PROTECTED], [EMAIL PROTECTED] says... Hi! mysql_error returns nothing... The error arrives while selecting the database via: $link = mysql_connect(host,user,passwd); mysql_select_db(bla, $link); echo $link returns always '1'! David Robley wrote: In article [EMAIL PROTECTED], [EMAIL PROTECTED] says... So, I've testet all possible I found in my brain... CGI or Apache module: same error mysql_connect or mysql_pconnect: same error Variing settings in php.ini: same error How can I solve that problem? BTW: Here I describe it again: Connecting to a database works well: ok Working with that database: ok Using the additional $link-Parameter: false Not a valid resource id ... And it does not matter how many different links with different servers I use! The resource-id is always '1'. Strange... Not a valid resource ID usually means a problem with the query - in fact this might be in the FAQ. Use mysql_error() after the database query to see if mysql returns a useful error. Guess I misread your question. However, a litle playing around with this script ?php $link1 = mysql_connect(localhost,a); $link2 = mysql_connect(localhost); echo 'Link 1: '.$link1 .'BR'; echo 'Link 2: '.$link2 .'BR'; if(mysql_select_db(test, $link1)) { echo 'Successful select of testBR'; }else{ echo 'Failed to select testBR'; } if(mysql_select_db(test2, $link2)) { echo 'Successful select of test2BR'; }else{ echo 'Failed to select test2BR'; } ? which gives this output Link 1: Resource id #1 Link 2: Resource id #2 Successful select of test Successful select of test2 seems to indicate that php is smart enough not to open a new link even if requested if there is already a link for the user! Removing the a in the first mysql_connect gives me two links with a resource ID of 1. I can force errors of course by feeding a wrong username/password which eventually leads to a 'Not a valid resource id' error but has other error messages as well. You aren't by chance hiding other error responses by using @ or 'or die'? -- David Robley Temporary Kiwi! -- 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]
Re: [PHP] Re: [PHP General] RE: Problems with MySQL-Link [3:14370:14592]
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 testBR'; } else { echo 'Failed to select testBR'; } ? gives this output: Warning: Supplied argument is not a valid MySQL-Link resource in /home/bt/bin/test.php on line 4 I don't know what to do... David Robley wrote: In article [EMAIL PROTECTED], [EMAIL PROTECTED] says... Hi! mysql_error returns nothing... The error arrives while selecting the database via: $link = mysql_connect(host,user,passwd); mysql_select_db(bla, $link); echo $link returns always '1'! David Robley wrote: In article [EMAIL PROTECTED], [EMAIL PROTECTED] says... So, I've testet all possible I found in my brain... CGI or Apache module: same error mysql_connect or mysql_pconnect: same error Variing settings in php.ini: same error How can I solve that problem? BTW: Here I describe it again: Connecting to a database works well: ok Working with that database: ok Using the additional $link-Parameter: false Not a valid resource id ... And it does not matter how many different links with different servers I use! The resource-id is always '1'. Strange... Not a valid resource ID usually means a problem with the query - in fact this might be in the FAQ. Use mysql_error() after the database query to see if mysql returns a useful error. Guess I misread your question. However, a litle playing around with this script ?php $link1 = mysql_connect(localhost,a); $link2 = mysql_connect(localhost); echo 'Link 1: '.$link1 .'BR'; echo 'Link 2: '.$link2 .'BR'; if(mysql_select_db(test, $link1)) { echo 'Successful select of testBR'; }else{ echo 'Failed to select testBR'; } if(mysql_select_db(test2, $link2)) { echo 'Successful select of test2BR'; }else{ echo 'Failed to select test2BR'; } ? which gives this output Link 1: Resource id #1 Link 2: Resource id #2 Successful select of test Successful select of test2 seems to indicate that php is smart enough not to open a new link even if requested if there is already a link for the user! Removing the a in the first mysql_connect gives me two links with a resource ID of 1. I can force errors of course by feeding a wrong username/password which eventually leads to a 'Not a valid resource id' error but has other error messages as well. You aren't by chance hiding other error responses by using @ or 'or die'? -- 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]
Re: [PHP] Re: [PHP General] RE: Problems with MySQL-Link [3:14370:14592]
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 testBR'; } else { echo 'Failed to select testBR'; } ? 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]