PHP Blog Admin Panel 3: How to give database connection in php mysql | Connection to MySql DB in php
HTML-код
- Опубликовано: 1 окт 2024
- In this video, I have taught how to give database connection in php mysql
Connection to MySql DB in php script.
PHP Blog Script in PHP MySQL Source Code:
www.fundacodes...
Playlist - PHP Blog Admin Panel:
• PHP Blog Admin Panel ...
Part 1: PHP Blog: Setup Admin Panel in PHP
• PHP Blog Admin Panel ...
Part 2: PHP Blog: How to setup frontend part in php with navbar, login and register page
• PHP Blog Admin Panel 2...
Part 3: PHP Blog: how to give database connection in php mysql
• PHP Blog Admin Panel 3...
Buy me a Coffee: www.buymeacoff...
Follow us on Instagram: / funda_of_web_it
Subscribe to my Hindi/Urdu Channel: / fundaofwebithindi
Awesome video. I did run into a problem with the dberror redirect, but fixed it by using a try-catch block in place of the if/else statement:
try{
$con = mysqli_connect($host, $username, $password, $database);
}catch(Exception $e){
header("Location: ../errors/dberror.php");
die();
}
same problem bro, thank you for the solution
Again sir heads off your affferts
amazing..thank you very much
how to redirect in to dberror.php?
why i cant redirect on dberror.php
I have done everything exactly, but it doesn't redirect to dberrors.php
this is the error I'm getting instead!
Warning: mysqli_connect(): (HY000/1049): Unknown database 'echrxsfsdspodvrt' in C:\xampp\htdocs\blog\admin\config\dbcon.php on line 8
Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\blog\admin\includes\sidebar.php:1) in C:\xampp\htdocs\blog\admin\config\dbcon.php on line 12
did you fix it ?
@@godfreypolicarpio3885 not been able to so I just moved. Will figure it out later. Its not really a big deal currently
@@paapaak ok thank you
How do I get the database
so long wait
awesome tutorial so far however i wrote the code exactly how you do however if the database is not connected I was not redirected to another page instead I get a error of
Fatal error: Uncaught mysqli_sql_exception: Unknown database 'blowg' in C:\xampp\htdocs\PHP-blog\admin\config\conn.php:7 Stack trace: #0 C:\xampp\htdocs\PHP-blog\admin\config\conn.php(7): mysqli_connect('localhost', 'root', '', 'blowg') #1 C:\xampp\htdocs\PHP-blog\admin\index.php(2): include('C:\\xampp\\htdocs...') #2 {main} thrown in C:\xampp\htdocs\PHP-blog\admin\config\conn.php on line 7
please could someone help
done, Sir
Thanks this tutorial series. I hope you will publish oop php tutorial series. Thanks
PLEASE SURE I HAVE THE SAME PROBLEM AS low zhi lok can you help?
Me too
Hello sir, I follow you the database connection but still cannot redirect to the dberror.php there. Can you hlp me?
This is index (In admin):
Welcom to the Admin Page!
Dashboard
Primary Card
View Details
Warning Card
View Details
Success Card
View Details
Danger Card
View Details
=============================================================
This is dbcon.php (In admin):
This is dberror.php (Outside admin):
Testing
?>
============================
why still cannot redirect to the "dberror.php"?
dbcon.php (In admin):
Hi! I encountered this same problem, were you able to fix it? If you don’t mind me asking, how did you fix it? I badly need it😭
$con = mysqli_connect('localhost','root','','databaseName'):
And make sure, the variable $con is same everywhere you use in application
If still not working, check xampp or wamp is started and try to connect.
@@fundaofwebit I tried it but it still won’t redirect to the dberror.php
I followed what you did in 4:37, and when I reload it again it displays this
Fatal error: Uncaught mysqli_sql_exception: Unknown database 'mai-admin' in C:\xampp\htdocs\php-blog\admin\config\dbcon.php:8 Stack trace: #0 C:\xampp\htdocs\php-blog\admin\config\dbcon.php(8): mysqli_connect('localhost', 'root', '', 'mai-admin') #1 C:\xampp\htdocs\php-blog\admin\index.php(2): include('C:\\xampp\\htdocs...') #2 {main} thrown in C:\xampp\htdocs\php-blog\admin\config\dbcon.php on line 8
Unknown database error means, it's not found.
And please rename or re-create your database without hyphens symbol.
Eg: mai_admin instead of mai-admin
amazing..thank you very much
I am not able to open my blogs in my website ? How can I identify a blog file in myphp data
Has anyone found a solution to redirecting to dberror.php? My code is exactly as it is in the video, but when I test with an incorrect database name, instead of redirecting to dberror.php, I get a "fatal error: Uncaught mysqli_sql_exception: Unknown database 'costingdfdfd'...."
It is not redirecting because, before it checks the database connection, there is some other query running it and that query is giving error.
So make sure it's on top and
You can try another way , instead of redirecting just
echo ' Database Connection Failed ';
exit();
Did you find the solution?