PHP database connection file including? Programming Web Development by zebnoon Dear friends, I am facining an other problem to in cloude a connetion file in PHP form.my code is below <?php include"conn.php"; if(isset($_POST['login'])){ $uname=$_post['username']; $uname=$_post['password']; $sql="SELECT * FROM login1 WHERE L1='$uname'"; $result=$conn->query(&… Re: PHP database connection file including? Programming Web Development by zebnoon My conn.php file is here.. <?php $username="root"; $password=""; $server="127.0.0.1"; $db="login1"; $conn=new mysqli($server,$username,$password,$db); if(!$conn){ echo "Connection not established"; } ?> Re: PHP database connection file including? Programming Web Development by cereal `login1` is the **database** name or the **table** name, or both? Instead of: if(!$conn){ echo "Connection not established"; } Do: if ($conn->connect_errno) { printf("Connect failed: %s\n", $conn->connect_error); exit(); } As suggested in the [documentation](http://php.net/… Re: PHP database connection file including? Programming Web Development by zebnoon ok But this code does give result ....any mistake here? $sql="SELECT * FROM login1 WHERE L1='$uname'"; $result=$conn->query("$sql"); if($result){ echo("welcome to new page"); } else { echo ("login problem"); } Re: PHP database connection file including? Programming Web Development by cereal It seems fine, the only problem I can see is related to the space between the include and the string: include"conn.php"; It should be: include "conn.php"; But at query level use `$result->error`: if($result){ echo "welcome to new page"; } else{ echo $result->error… Re: PHP database connection file including? Programming Web Development by zebnoon if($result->num_rows==true){ echo("welcome"); } else { echo ("invalid username"."<br>"); } I have solved with that code...its ok? Re: PHP database connection file including? Programming Web Development by cereal Mysqli `num_rows` returns integers not booleans (`true|false`) so if you want to check how many rows you're returning change the if statement to: if($result->num_rows > 0){ But, if the query fails for an error this statement will not prevent a PHP notice: PHP Notice: Trying to get property of non-object ... It happens …