SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Wizard lukeurtnowski's Avatar
    Join Date
    Mar 2003
    Location
    Coronado
    Posts
    1,645
    Mentioned
    3 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
    SitePoint Mentor bronze trophy
    John_Betong's Avatar
    Join Date
    Aug 2005
    Location
    City of Angels
    Posts
    1,838
    Mentioned
    73 Post(s)
    Tagged
    6 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.
    Learn how to be ready for The New Move to Discourse

    How to make Make Money Now with a *NEW* look

    Be sure to congratulate Patche on earning Member of the Month for July 2014


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
  •