0

O have gone though the list of similar error and I didn't see the one that works with mine. Am out of time on this job but can still get it. am not an expert yet on php, please I need help on the code below.

$db = mysqli_connect("localhost", "joy", "hvkgigkgijhkhi");
    if(!$db){
        echo "No DB";
    }else{
        $query = "SELECT * FROM member WHERE uname= '$uname'";
        mysqli_select_db("testing",$db);
        $results = mysqli_query($query);
        if(!$results){
            die('Could not connect: ' . mysqli_connect_error());
        }else{
            while ($row = mysqli_fetch_array($results,MYSQL_ASSOC)) {
                //$row.$_SESSION['uname'] = $uname;
                $row.$_SESSION['fullname'] = $Fname;
                $row.$_SESSION['my_ref_id'] = $My_ref;
                //$row.$_SESSION['email'] = $email;
                //$_SESSION['success'] = "You are now logged in";
                //header('location: index.php');
            }
        }
    }
        ?>
  <!-- logged in user information -->
     <div class="menue">
        <?php  if (isset($_SESSION['uname'])) : ?>
            <p>Refferal Pin: <strong><?php echo $My_ref; ?></strong><br></p>
            <p>Full Name: <strong><?php  echo $_SESSION['fullname']; ?></strong><br></p>
            <p>User Name: <strong><?php echo $_SESSION['uname']; ?></strong><br></p>
            <p>Email Address: <strong><?php echo $_SESSION['email']; ?></strong><br></p>
            <p> <a href="index.php?logout='1'" style="color: red;">logout</a> </p>
        <?php endif ?>
     </div>
Dharman
  • 30,962
  • 25
  • 85
  • 135
  • 1
    Try mysqli_select_db($db, "testing"); http://php.net/manual/en/mysqli.select-db.php – Stephen Kennedy Jan 06 '18 at 16:01
  • 1
    Possible duplicate of [mysqli\_select\_db() expects parameter 1 to be mysqli, string given](https://stackoverflow.com/questions/13979210/mysqli-select-db-expects-parameter-1-to-be-mysqli-string-given) – dferenc Jan 06 '18 at 21:51
  • i have tried mysqli_select_db($db,'testing');but it still gave me the same error – Anthony Holland Jan 07 '18 at 11:24

1 Answers1

1
mysqli_select_db($con,"wrox_database"); //first connection then database name.

This works for me.

duplode
  • 33,731
  • 7
  • 79
  • 150
iyer
  • 11
  • 1
  • @d_kennetz There is no need to add "edited for proper indent" to the body of the post -- the edit summary is enough for explaining that. – duplode Oct 01 '18 at 17:50
  • @duplode I am relatively new to the editing side of things, but when I just fix an indent it says "edits must be at least 6 characters long". How do I get around this? – d_kennetz Oct 01 '18 at 17:56
  • @d_kennetz If you can't make your suggested edit more than six characters long in a natural way, it is better to not do it, and leave it to 2000+ reputation users, which are not subject to the limit. In such cases, if you want to help the OP improve their post, one option is leaving a comment explaining what they should do. – duplode Oct 01 '18 at 18:10
  • @duplode I see! I will be aware of this in the future, thanks for taking time to explain. – d_kennetz Oct 01 '18 at 18:13