www.webdeveloper.com
Results 1 to 4 of 4

Thread: Don't select db

  1. #1
    Join Date
    Apr 2014
    Posts
    2

    Don't select db

    Hello Friends.

    I was created a db and a table. When i was try connect the db not connected. Only open server don't connect db.
    I was try many type of change the code but not get success. Please see the code. Please help me anyone.

    Type 1.
    <?php


    $db_handle = mysql_connect("localhost","ssstcoin_Sar","mypassword");
    if (mysqli_connect_errno())
    {
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
    }

    print "Connection to the Server opened";

    $db_found = mysql_select_db( "localhost", $ssstcoin_dw ,$con);
    if($db_found)
    {print "db found";}
    else{print "db not found";}

    ?>

    Type 2.
    <?php


    $db_handle = mysql_connect("localhost","ssstcoin_Sar","mypassword");
    if (mysqli_connect_errno())
    {
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
    }

    print "Connection to the Server opened";

    $db_found = mysql_select_db($ssstcoin_dw ,$con);
    if($db_found)
    {print "db found";}
    else{print "db not found";}

    ?>

    Type 3.
    <?php


    $db_handle = mysql_connect("localhost","ssstcoin_Sar","mypassword");
    if (mysqli_connect_errno())
    {
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
    }

    print "Connection to the Server opened";

    $db_found = mysql_select_db( $database ,$link);
    if($db_found)
    {print "db found";}
    else{print "db not found";}

    ?>

    After uploaded the code see bellow error .

    Connection to the Server opened<br />

    <b>Warning</b>: mysql_select_db() expects at most 2 parameters, 3 given in <b>/home/ssstcoin/public_html/test.php</b> on line <b>12</b><br />
    db not found<br/><br/><br/>

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,637
    You cannot (successfully) combine mysqli_*() and mysql_*() functions. I'll let you figure out if it's just a typo, or a deeper problem.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  3. #3
    Join Date
    Apr 2014
    Posts
    2
    Hi.. I was already changed but not success. Please give any one good answer.

  4. #4
    Join Date
    Dec 2002
    Location
    Seattle, WA
    Posts
    1,843
    MySQLi uses mysql_select_db() as a parameter of mysqli_connect()
    PHP Code:
    <?php
    $sql_username 
    'ssstcoin_Sar';
    $sql_password 'password';
    $sql_database ''// need a valid dbname here

    $link mysqli_connect(NULL$sql_username$sql_password$sql_database);
    unset(
    $sql_username$sql_password);

    if ((
    $error mysqli_connect_error())) {
        echo 
    'Failed to connect to MySQL: ' $error;
    }
    echo 
    'Connection to the Server opened';
    mysqli_close($link);
    ?>

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