Can't use db : No database selected

Hi,

I have a new LAMP install, that seem to work perfectly - individually.
Apache, MySQL, PHP and phpMyAdmin

Trying to connect PHP and MySQL

Using

> <?
> $username=“username”;
> $password=“password”;
> $database=“username-databaseName”;
> ?>

and then

> // Opens a connection to a MySQL server
> $connection = mysql_connect (“localhost”, $username, $password);
> if (!$connection) {
> die('Not connected : ’ . mysql_error());
> }
>

when i load the page i get the error

> Can’t use db : No database selected

Please help


d_quixote

d_quixote’s Profile: http://forums.opensuse.org/member.php?userid=21578
View this thread: http://forums.opensuse.org/showthread.php?t=407117

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

A few things… mysql_connect (in PHP) returns a resource, not a
boolean, so be careful there. With that said…

Finish it:

http://us2.php.net/mysql_select_db

Good luck.

d quixote wrote:
> Hi,
>
> I have a new LAMP install, that seem to work perfectly - individually.
> Apache, MySQL, PHP and phpMyAdmin
>
> Trying to connect PHP and MySQL
>
> Using
>
>> <?
>> $username=“username”;
>> $password=“password”;
>> $database=“username-databaseName”;
>> ?>
>
> and then
>
>> // Opens a connection to a MySQL server
>> $connection = mysql_connect (“localhost”, $username, $password);
>> if (!$connection) {
>> die('Not connected : ’ . mysql_error());
>> }
>>
>
> when i load the page i get the error
>
>> Can’t use db : No database selected
>
> Please help
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFJjEyh3s42bA80+9kRAn1pAJ4hA9ufnNvNAAnJYFjiwwfGLqP/ewCfQZBR
/REbbflz1lK1yu+nCtRIbTE=
=0uf3
-----END PGP SIGNATURE-----

It worked! Thank you.


d_quixote

d_quixote’s Profile: http://forums.opensuse.org/member.php?userid=21578
View this thread: http://forums.opensuse.org/showthread.php?t=407117