-4
<html>
<body>
    <?php
    $servername="localhost";
    $username="STARK-PC";
    $password="YES";
    $dbname="kishan";
    $conn=new mysqli("localhost","STARK-PC","YES","kishan");

my database not select so what i can do for select my database ?

3 Answers3

2

May be you are putting your pc name to your mysql username and password If you are using default mysql settings you can put.

    $servername="localhost";
    $username="root";
    $password="";
    $dbname="kishan";
    $conn=new mysqli($servername,$username,$password,$dbname);
MOHD TAHIR
  • 151
  • 1
  • 1
  • 11
1

For the sake of argument, I will not tell you actually that this is bad habit to put your info out like that in your html file. (since it is).

However, first of all, did you create those variables (as is this info in your phpmyadmin?) Asuming it is not, use the following:

$servername="localhost";
$username="root";
$password="";
$dbname="kishan";
$conn=new mysqli($servername,$username,$password,$dbname);

Root is the standard username, password is by default blank with this user.

Further, as you see, those variables you put down, you dont use them, which you should. Check the last line. I used those variables, instead of the content of those variables.

Also, just a headsup if you want to include this in your file: start this BEFORE you open the html.

<?php
    $servername="localhost";
    $username="root";
    $password="";
    $dbname="kishan";
    $conn=new mysqli($servername,$username,$password,$dbname);
?>
<html>
<body>

Good luck

Dorvalla
  • 5,027
  • 4
  • 28
  • 45
0
$conn=mysqli_connect('localhost', 'STARK-PC','YES') or die('check your user name or password');
mysqli_select_db($conn,'kishan') or die('error in your database');

try this and check error message and solve that..... thanks