Results 1 to 6 of 6

Thread: [RESOLVED] select database problem

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 2009
    Location
    Australia, Melbourne
    Posts
    29

    Resolved [RESOLVED] select database problem

    PHP Code:
        $con mysql_connect("localhost","user1","password") or die("Cannot connect");
                                
    mysql_select_db("pmonty7_dsd"$con) or die("Cannot select database");
                                
    $query "SELECT * FROM randquote ORDER BY Rand() LIMIT 1";
                                
    $result mysql_query($query,$con) or die("Result Query Error");
                                
    while(
    $rows mysql_fetch_array($result))
    {
        echo 
    $rows['quote'] . " " $rows['LastName'];
        echo 
    "<br />";
    }
    mysql_close($con); 
    I am getting the die message "Cannot select database"

    I have no idea host is all workign fine and so is phpmyadmin and so on. But cant figure it out. also the name and table name are 100% correct.

    Any idea guys?

  2. #2
    Member
    Join Date
    Nov 2012
    Posts
    38

    Re: select database problem

    bump your error level up (with error_reporting) and see what actual error the sql lib gives you

    PHP Code:
    error_reporting(E_ALL

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Aug 2009
    Location
    Australia, Melbourne
    Posts
    29

    Re: select database problem

    Just added it now and still get the same message "Cannot select DB"... is it not recognizing the dbname or is it a issue on the mysql configuration end?

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Aug 2009
    Location
    Australia, Melbourne
    Posts
    29

    Re: select database problem

    hmm i added mysql_Error() and it says access denied for 'pmonty7_admin'@'localhost' to 'pmonty7_dsd'

  5. #5
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: select database problem

    Quote Originally Posted by SharpCode View Post
    hmm i added mysql_Error() and it says access denied for 'pmonty7_admin'@'localhost' to 'pmonty7_dsd'
    Check whether user1 has appropriate permission to access your database pmonty7_dsd.


    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Aug 2009
    Location
    Australia, Melbourne
    Posts
    29

    Re: select database problem

    yeh seems the user i made wasn't added to the database... common sense -.-

Posting Permissions

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



Click Here to Expand Forum to Full Width