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

Комментарии • 32

  • @TheQueen0fGames
    @TheQueen0fGames 8 месяцев назад +1

    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();
    }

    • @jamirdaquiz6339
      @jamirdaquiz6339 5 месяцев назад

      same problem bro, thank you for the solution

  • @mohitshastri828
    @mohitshastri828 2 года назад +3

    Again sir heads off your affferts

  • @AhmedAbdo-hs5gn
    @AhmedAbdo-hs5gn Год назад +1

    amazing..thank you very much

  • @CodeExplorer_
    @CodeExplorer_ Год назад +1

    how to redirect in to dberror.php?

  • @godfreypolicarpio3885
    @godfreypolicarpio3885 Год назад +2

    why i cant redirect on dberror.php

  • @paapaak
    @paapaak Год назад +1

    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

    • @godfreypolicarpio3885
      @godfreypolicarpio3885 Год назад

      did you fix it ?

    • @paapaak
      @paapaak Год назад +2

      @@godfreypolicarpio3885 not been able to so I just moved. Will figure it out later. Its not really a big deal currently

    • @godfreypolicarpio3885
      @godfreypolicarpio3885 Год назад

      @@paapaak ok thank you

  • @martinettlin7996
    @martinettlin7996 6 месяцев назад

    How do I get the database

  • @TusharZambare
    @TusharZambare 2 года назад +1

    so long wait

  • @2-dsenpai164
    @2-dsenpai164 Год назад

    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

  • @mahbubafaruki2468
    @mahbubafaruki2468 2 года назад +1

    done, Sir

  • @mdjabedbhuiyan
    @mdjabedbhuiyan 2 года назад

    Thanks this tutorial series. I hope you will publish oop php tutorial series. Thanks

  • @elmounchitayoub
    @elmounchitayoub 2 года назад

    PLEASE SURE I HAVE THE SAME PROBLEM AS low zhi lok can you help?

  • @lowzhilok8261
    @lowzhilok8261 2 года назад +1

    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"?

    • @michaellev7599
      @michaellev7599 2 года назад

      dbcon.php (In admin):

    • @kristhayne2658
      @kristhayne2658 2 года назад

      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😭

    • @fundaofwebit
      @fundaofwebit  2 года назад

      $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.

    • @kristhayne2658
      @kristhayne2658 2 года назад

      @@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

    • @fundaofwebit
      @fundaofwebit  2 года назад

      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

  • @suraalani6835
    @suraalani6835 2 года назад

    amazing..thank you very much

  • @paritoshpandya3287
    @paritoshpandya3287 2 года назад

    I am not able to open my blogs in my website ? How can I identify a blog file in myphp data

  • @c4rp3v1num
    @c4rp3v1num Год назад

    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'...."

    • @fundaofwebit
      @fundaofwebit  Год назад

      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();

    • @منتصركاظم-ق2ق
      @منتصركاظم-ق2ق 11 месяцев назад

      Did you find the solution?