SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: error when establishing a connection

  1. #1
    SitePoint Wizard lukeurtnowski's Avatar
    Join Date
    Mar 2003
    Location
    Coronado
    Posts
    1,484
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    error when establishing a connection

    Im using this php code to see if I can connect to my database.
    PHP Code:
    $username="fixmy1_luke";
    $password="xxx";
    $server="localhost";
    $database="fixmy1_shores-rentals";

    $db_handle mysql_connect($server$username$password);

    $db_found mysql_select_db($database$db_handle);

    if (
    $db_found) {
    print 
    "Database Found " $db_handle;
    }
    else {
    print 
    "Database NOT Found " $db_handle;

    at
    http://fixmysite.us/shores-classified/rentals.php
    What does that mean? is it an error?

    thanks
    "Oh, and Jenkins--apparently your mother died this morning."

  2. #2
    Community Advisor bronze trophy
    John_Betong's Avatar
    Join Date
    Aug 2005
    Location
    City of Angels
    Posts
    1,138
    Mentioned
    34 Post(s)
    Tagged
    2 Thread(s)
    Try this:

    PHP Code:
      $username="fixmy1_luke";
      
    $password="xxx";
      
    $server="localhost";
      
    $database="fixmy1_shores-rentals";
      
      
    $db_handle mysql_connect($server$username$password);
        echo 
    '<br />';
        
    var_dump($db_handle);

    # is connection OK?
    if($db_handle
    {  
        
    $db_found mysql_select_db($database$db_handle);
        echo 
    '<br />';
        
    $var_dump($db_found);
      
       echo 
    '<br />';
       if (
    $db_found)
       {
         print 
    "Database Found " .$db_found// $db_handle;
       
    }
       else
       {
         print 
    "Database NOT Found " .$db_found//  $db_handle;
       
    }  
    }
    else
    {
       echo 
    '<br />';
       echo 
    'Unable to connect to the dtabase';

    Your message states that a mysql_connect(...) connection resource was found but it looks like the database name is incorrect.

Bookmarks

Posting Permissions

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