You are here: Re: No database selected « All PHP « IT news, forums, messages
Re: No database selected

Posted by Sjaakie on 05/23/05 12:39

Shelly wrote:
> I have identical names for the database, user and password on the local
> machine and on the remote site. I also have identical tables and info in
> the tables. It works perfectly on the local machine. On the remote site I
> get "No Database Selected". It happens in the mysql_query call.
>
> echo "ssLogin = " . $ssLogin . " ";
> $LoginRS = mysql_query($LoginRS__query, $ssLogin) or die(mysql_error());
> echo "LoginRS = " . $LoginRS;
>
> This gives:
> ssLogin = Resource id #3 No Database Selected
>
> On both machines I have have a require file which is:
>
> <?php
> # FileName="Connection_php_mysql.htm"
> # Type="MYSQL"
> # HTTP="true"
> $hostname_ssLogin = "localhost";
> $database_ssLogin = "the_database_name";
> $username_ssLogin = "the_username";
> $password_ssLogin = "the_password";
> $ssLogin = mysql_pconnect($hostname_ssLogin, $username_ssLogin,
> $password_ssLogin) or die(mysql_error());
> ?>
>
> I thought it might be the $hostname_ssLogin, that it had to be something
> else. However, if it is not localhost, then the mysql_pconnect fails.
>
> Any ideas?
>
> Shelly



I'm assuming you are very sure you want to use mysql_pconnect (and
establish a persistant connection) instead of mysql_connect. If not have
a look at http://nl2.php.net/mysql_pconnect.

Have you selected your database?
mysql_select_db ("the_database_name");

Does you user have enough permissions?
Run this query :
GRANT ALL ON the_database_name.* TO the_username
and try again.

I am used to query a database in this order:
$oCon=mysql_connect('host', 'login', 'pass');
mysql_select_db('database', $oCon);
$result=mysql_query('select * from table', $oCon) or die(mysql_error());
....
mysql_close($oCon);

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация