Menu
Menu
DaniWeb
Log In
Sign Up
Read
Contribute
Meet
Search
Search
About 7 results for
cloude9
- Page 1
PHP database connection file including?
Programming
Web Development
9 Years Ago
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
9 Years Ago
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
9 Years Ago
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
9 Years Ago
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
9 Years Ago
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
9 Years Ago
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
9 Years Ago
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 …
Search
Search
Forum Categories
Hardware/Software
Programming
Digital Media
Community Center
Latest Content
Newest Topics
Latest Topics
Latest Posts
Latest Comments
Top Tags
Topics Feed
Social
Meet People
Forums
Top Members
Community Functions
DaniWeb Premium
Newsletter Archive
Markdown Syntax
Community Rules
Developer APIs
Connect API
Forum API Docs
Tools
SEO Backlink Checker
Legal
Terms of Service
Privacy Policy
FAQ
About Us
Advertise
Contact Us
© 2024 DaniWeb® LLC