www.webdeveloper.com
Results 1 to 3 of 3

Thread: connect to mySQL database issues

  1. #1
    Join Date
    Apr 2006
    Posts
    15

    connect to mySQL database issues

    Hi,

    I've been trying all sorts of different ways to connect to my database but keep getting this error:

    Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource

    I talked to my hosting company and they day the database is fine and it must be the php code which they can't support me on. I am quite new with PHP so it is probably me. Here is my code:

    <?
    $Database = mysql_connect("localhost", "username", "password");
    mysql_select_db("mydatabase", "$Database");
    ?>

    I checked my user name and password, both are correct.

    Any suggestions? Thanks in advance.

  2. #2
    Join Date
    Sep 2003
    Location
    Netherlands
    Posts
    353
    remove the quotes around the $Database string in the select.
    PHP Code:
    <?
    $Database 
    mysql_connect("localhost""username""password");
    mysql_select_db("mydatabase"$Database);
    ?>

  3. #3
    Join Date
    Apr 2006
    Posts
    15

    Thanks!

    that worked great, no error.

    Thanks you so much. I should buy a PHP book...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles