Want more? Explore the library at https://www.codecourse.com/lessons Official site https://www.codecourse.com Twitter https://twitter.com/teamcodecourse.
Original source
Want more? Explore the library at https://www.codecourse.com/lessons Official site https://www.codecourse.com Twitter https://twitter.com/teamcodecourse.
Original source
25 responses to “PHP Tutorials: Register & Login (Part 4): Database Connection”
can I get that full folder , that u have coded.
Everything worked up until i added include 'core/init.php'; in my index.php now i get a blank screen when i refresh index.php.
here is my index .php
<?php
include 'core/init.php';
include 'includes/overall/header.php';
?>
<h1>home</h1>
<p>template</p>
<?php include 'includes/overall/footer.php'; ?>
and my init.php
<?php
session_start();
error_reporting(0);
require 'database/connect.php';
?>
and my connect.php
<?php
$connect_error = 'sorry, we're expirencing connection problems.';
mysql_connect('localhost', 'root', '') or die ($connect_error);
mysql_select_db('gl') or die ($connect_error);
?>
Use this code if anyone face any error while connecting database!
<?php
$conn = mysqli_connect("localhost", "root", "", "DatabaseName");
if (!$conn) {
# code…
die("Connection failed: ".mysqli_connect_error());
}
?>
help me pls my skype facebook:pandelus.mario.7
Warning: session_start() [function.session-start]: Cannot send session cache limiter – headers already sent (output started at C:xampphtdocswanderlustindex.php:14) in C:xampphtdocswanderlustcoreinit.php on line 2
For those who are having trouble with mysql connect, try this:
<?php
$DBhost = "localhost";
$DBuser = "root";
$DBpass = "";
$DBname = "dbname";
$DBcon = new MySQLi($DBhost,$DBuser,$DBpass,$DBname);
if ($DBcon->connect_errno) {
die("ERROR :
> ".$DBcon>connect_error);}
If I include init.php file I cannot able to see the the webpage completely.
why session_start in init.php?
why have you used session_start?
Hi, I have declared $error on the init.php, however, when I include "core/init.php" on the login page it displays a blank page and I cannot implement $error array variable in a login page can someone please help me?
When I try to connect to my localhost/index.php after adding in the include for core/init.php it will not load, it times out? Any ideas on how to fix this???
i need source code with css please
+nemanja1a2a Thank you
But it still does not recognize the 3functions: mysqli_connect and mysqli_select_db and session_start()
Do you have any helpful solution for that ?
I hope that you will revisit this tutorial for a new update. As of the latest release of MySQL (as of 2015) there is a message that coders will see when writing out the commands: "Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead"
This is a real issue because they no longer be available, and everyone will have to upgrade to MySQLi or PDO. The change will be drastic as MySQLi uses a different method of connecting to databases than traditional MySQL.
im getting :
Warning: session_start() [function.session-start]: Cannot send session cache limiter – headers already sent (output started at F:xampplitehtdocslibrarymain.php:2) in F:xampplitehtdocslibrarycoreinit.php on line 2
How do i fix this?
mysqli should be used instead of mysql. mysql is outdated and deprecated.
uh-oh mysql is depreciated for anyone getting an error.
replace anything called "mysql" with "mysqli"
this is why code is sometime frustrating. no freaking standards!
Random question but my stylesheet wont work with my page anymore. Well it does but when I try putting new values into it then it wont work so I have to do inline styles…. Help?
+nemanja1a2a Thank you for fixing that error! Wouldn't have found it without you (y)
Please help i cant get the error (im hosting on byethost)
This worked for me if you are having problems with the connect.php file
<?php
$connect_error = 'Error message';
$con = mysqli_connect('localhost','root','');
mysqli_select_db($con,'test') or die($connect_error);
?>
i cant find my privileges tab
Problem with any programming language: they always change, I think some of this no longer relevant.
Deprecated mysql_, and include continues where require shows errors: In connect.php, replace mysql_connect and the next line with: mysqli_connect('localhost','root','','lr') or die($connect_error);
then in index.php change include 'core/init.php'; into require ''core/init.php';.
When you change the params of mysqli_connect to check errors, it will show the error msg.
breaking up doesn't work please help! I sent an email to you