PHP Front To Back [Part 21] - Fetching Data With MySQLi

Поділитися
Вставка
  • Опубліковано 12 гру 2024

КОМЕНТАРІ • 141

  • @shargenezangana9320
    @shargenezangana9320 5 років тому +15

    Thank you for your time in making this video. Thank you for helping others on a path to providing a better life. Blessings to you and your family.

  • @d.o.balogun3228
    @d.o.balogun3228 Рік тому

    You tuts are simple and easy to follow.
    As a beginner, I am to follow what you are teaching without much difficulty.
    Thank you.

  • @RajatSharma-mm7of
    @RajatSharma-mm7of 6 років тому +2

    Hey man, you actually do not know, you are getting thousand of blessings from us. You are simply UA-cam legend. #respect

  • @bg73
    @bg73 7 років тому

    Finally, a PHP tutorial that renders PHP down in the HTML code. So many tutorials out there where they don't show you how to add PHP with your HTML, especially for repeated regions.

  • @pab_loq
    @pab_loq 7 років тому +16

    i wake up today telling myself 'aaah i have to learn that SQL+PHP stuff...' and before looking for it, there it was, in my feed. You're freaking me out! Thank you!!

    • @cla1814
      @cla1814 6 років тому

      It's not him is google. Now google can read our mind with Ai lol.
      I had video in my fee with problem I had in my mind that I didn't even look on google or youtube!

  • @successfulpeople
    @successfulpeople 6 років тому

    Some people are just blessed with the gift of sharing knowledge. Brad, you are blessed with that gift. I have never used MySQL and have never learned it before but after watching this video, I feel like an expert. I will check out your other video you mentioned regarding MySQL. Thank you once again for a job well done.

  • @bas3q
    @bas3q 7 років тому +2

    Thanks for continuing to keep this series updated, Brad. I can only speak for myself, but I'm really enjoying it...and no worries about the delay in getting parts up, it gives me time to go back and write test code to make sure I really understand each part before going on to the next one. Cheers!

  • @TimGallant
    @TimGallant 5 років тому

    Thanks so much for all this, Brad.
    Just a note that in real world application, the entire section of the page should *not* be put in a common header unless you define all your page titles and descriptions dynamically, so that they're not the same across every page.

  • @nikolay5542
    @nikolay5542 2 роки тому +1

    If someone is getting an error at 11:23, check also how you named the table in the database - post or posts. If it was post change all posts to post in the index.php file.

  • @pepeback
    @pepeback 7 років тому

    Hi Brad, for preparing SQL queries, it is VERY handy to use HEREDOC sintax.
    The easiest way to prepare strings. No escape needed at all. And also valiables are evaluated. BIG THANKS for your tutorials.

  • @manishpandey2083
    @manishpandey2083 4 роки тому

    Thank you for all your videos Brad. There are lots of videos on coding, but your videos are the one that help with real projects. The way you explain things really click and the things you explain are really important.... I actually utilised everything taught in this video in a CMS/Blog project I am currently working on. Though I improvised a lot, but what you taught makes the foundation upon which I am building. Thank you again.. and all the very best with everything... Regards.

  • @je-suis-alin
    @je-suis-alin 7 років тому +8

    To be honest, I like videos with "face time :D". It brings you closer to us.
    Keep up your good work!

  • @bidam1984
    @bidam1984 7 років тому

    i just want to say thank you for being such a nice person and share all this knowledge for free, your heart is big like the universe ,may god bless you and your family

  • @busyrand
    @busyrand 6 років тому

    This was an Outstanding Lesson! Super fun and I learned a lot of really cool functional uses of PHP using SuperGlobals and Includes. My favorite part was the Bootstrap Navbar at the ending [had to 'develop' a bit on my own cuz Bootstrap has changed a bit since this was released]. That was the most straightforward demonstration of how to scaffold using Bootstrap I've ever seen. This has been a very valuable resource and I'm super thankful I have access to it. Thanks Brad!

  • @webhelp4574
    @webhelp4574 5 років тому +1

    when you were clicking 'new folder' it was actually working but was hidden behind your windows taskbar and was half visible. Nice stuff btw.

  • @mushegh_k
    @mushegh_k 7 років тому

    Hey Brad.
    In SublimeText when you click new folder, first you need to give a name hit enter then you folder will add to the project, look at the 22:57 on the bottom you need to name you folder.
    Thanks for your videos, i like the way you teach, i have learned alot!
    keep up the great work.

    • @TraversyMedia
      @TraversyMedia  7 років тому +1

      Ahh, I've been using Atom.io too long :)

    • @stefan4800
      @stefan4800 7 років тому +1

      Did you guys noticing how VC code becoming better and better? For me, Atom is kind of slow and buggy and I think many will start to flee toward VC code (like myself) and eventually, I'm afraid, VC code will start to cost money when VC suppress Atom. I'm afraid Atom will start to fading away without stable fonding.

  • @iflynina
    @iflynina 7 років тому +2

    Can't wait for the next one! I've been looking for a tutorial on how to submit form data to a database for a week now and can't get something that works for some reason.

  • @donvictor6999
    @donvictor6999 7 років тому +9

    You are a life saver Brad!!

  • @rupamshaw
    @rupamshaw 4 роки тому +1

    awesome helped a lot to understand php in short time

  • @King-Gilamashur2758
    @King-Gilamashur2758 4 роки тому

    This one worked like a charm and following along makes me feel like I've grasped a bit more of the concepts even though obviously I couldn't do this on my own yet. But overall great project thanks a ton!

  • @thomasnn
    @thomasnn 7 років тому

    I have used php for some months now, and I learned about the include html trick - somehow never knew this... thanks!

  • @prsion1925
    @prsion1925 6 років тому +2

    7:50 create new folder - down below in st3- clear field )

  • @djordjearsenovic
    @djordjearsenovic 7 років тому

    Hi Brad. This was awesome I have learned a lot. Please but PLEASE continue with this series! You are awesome!

    • @TraversyMedia
      @TraversyMedia  7 років тому +1

      Make sure you check the PDO video as well. Ill be doing more with PHP very soon

    • @djordjearsenovic
      @djordjearsenovic 7 років тому

      I am doing that right now, because I need to query DB2 database with php, and add data to the mysql after that. Thanks for your reply.

  • @MichalMonday
    @MichalMonday 4 роки тому +2

    If styling (navbar + "well" class) doesn't look right, you can change "4" into "3" in the link below:
    bootswatch.com/4/cerulean/bootstrap.min.css

    • @mika8145
      @mika8145 4 роки тому +1

      Cheers bro I was wondering why it aint working, inspecting elements and all.

    • @luussive3651
      @luussive3651 2 роки тому +1

      OMG Thank you so much kind sir, I was wondering for almost an hour why the navbar is not working

  • @WinadiWiratama
    @WinadiWiratama 6 років тому +3

    I'm confused in 22:27 you set the $conn with the constant created in config.php. Is it not necessary to use require('config/config.php'); ?

    • @fabiodeabreu723
      @fabiodeabreu723 6 років тому +9

      It isn't because in the index.php and post.php files he first require config.php and then db.php so each time he run index or post the server will run config.php and define the constant and only them use it on db.
      If you would only run the db.php then u would need to require it.
      Hopefully its clear haha.

    • @hermanomark
      @hermanomark 6 років тому

      @@fabiodeabreu723 thanks!

  • @AK-ur5me
    @AK-ur5me 7 років тому

    If you are taking any requests (and I know it is too much to ask but ;) before getting in to the forms or while getting in to the forms ( because I am sure we will be getting in to POST, PUT and possibly DELETE functions.)
    -Is it possible for you to create a second table for Tags, left_join it with the post tables and use Split function to populate the tags. So when you will create the forms, you create another input text box to make the tags and the amount of spaces that you have for input will split the input words in to tags.
    -Is it possible to use Sha Hashing /Hashing that is offered by JQuery for admin login?
    This is just a request, it is all good and understandable if you are planning to keep this tutorial just simple and on point.
    As for this tutorial. Thank you for the update on php series. I really admire your work and you are indeed an extremely reliable source for developers / web developers like me.

  • @robertcoffie8789
    @robertcoffie8789 7 років тому +8

    Finally.............................................................................................. thanks Man

  • @dmitriykozmin3091
    @dmitriykozmin3091 7 років тому

    once again thank you so much! it all starts to make sense after your explanations!

  • @javxa
    @javxa 4 роки тому

    These tutorials are just incredible! Thank you so much!

  • @TheFGrox
    @TheFGrox 7 років тому +1

    Thanks for these well explained lessons.
    Will you ever make a tutorial on how to build a multi language site with PHP?

  • @roashans3506
    @roashans3506 6 років тому +1

    13:45 ...He displays the "title" and "created_on" values of array $posts.......but uses $post instead of $posts .....is that alright?

    • @aminelouni
      @aminelouni 6 років тому +1

      $post because he use Foreach .. so he iterate throught the assoc list

  • @oosacker
    @oosacker 4 роки тому +1

    You might also have to specify the port you are using when you connect to the database. I was using MySQL Server and I had to say 'localhost:3307'.

    • @brettgattinger3338
      @brettgattinger3338 4 роки тому

      This saved me from a massive headache, thank you.

    • @kaustubhpatil3796
      @kaustubhpatil3796 3 роки тому

      how to know which localhost is running in my machine
      Warning: mysqli_connect(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: YES) in C:\xampp\htdocs\phpsandbox\blogs\index.php on line 4
      failed to connect ot MySQl1045
      I'm getting this error when I use localhost

  • @Chibisenpai2
    @Chibisenpai2 5 років тому

    Awesome vid as always. So this video just uses only procedural PHP? ( I remember him mentioning both object and procedural at 0:53)

  • @website_garage
    @website_garage 7 років тому

    Hi Brad, I love your tutorials here on UA-cam and been watching them for a while now and they are very good.
    Maybe a bit off topic but can you do a tutorial(series) about Docker. That would be very nice. Thanks in advance!

  • @sergeialekseenko3545
    @sergeialekseenko3545 3 роки тому

    Thank you for your job man!Where I can get your Laravel course?

  • @nasibullomukhamedov687
    @nasibullomukhamedov687 2 роки тому

    code from video gives error , please give source code with corrections

  • @GMCrelan
    @GMCrelan 6 років тому

    14:16 my output is very different from the video... the div of post one and post two box shadow... i don't have it

  • @RameenFallschirmjager
    @RameenFallschirmjager 5 років тому +3

    damn! programming is enjoyable as fuck! I love it! I've been coding for several years, but never it had never tasted good as now! thanks brad for great tutorials.

  • @bleemy
    @bleemy 6 років тому

    Hi, following your video works well, but when i want to pull the FULLNAME field from a different table it constantly gets an error, i am guessing this is because the script it only pointing at the original table, so how would i include a second table for this to look into to find a vairable (FULLNAME)

  • @tomkluskens4035
    @tomkluskens4035 2 роки тому

    I get an error saying that my array key "id" is not defined in the post.php file, my code is the same as yours. Do you maybe have an idea why I get that error?

  • @sabahkhan7782
    @sabahkhan7782 4 роки тому +2

    mysqli_connect(): (HY000/1045): Access denied for user 'root'@'localhost'(using password: YES)
    what's this mean? Actually I'm newbie in PHP so I don't know much about stuff like that so anyone? I need some help

    • @alfahami5210
      @alfahami5210 4 роки тому

      Check your password, it's not the same as what you put while creating mysql root user.
      If you didn't set one then try this : mysql -u root -p mysql

    • @prophaleous7427
      @prophaleous7427 3 роки тому

      I also need help on this....

  • @aresxena6632
    @aresxena6632 6 років тому +1

    Bit confused as to why you included 'ROOT_URL' to the index.php file. It only breaks things on my end, and seems unecessary in general.

    • @Jay-eg7yt
      @Jay-eg7yt 5 років тому

      It helps keep everything nicely organized. If this info changes in the future you can access and change it instantly without having to scroll thru several lines of code. It shouldn't break. Perhaps you forgot to require the file?

  • @adnanrruka5152
    @adnanrruka5152 5 років тому +1

    mysqli_connect doesn't work.
    Can't find any solution :(

  • @ahmedrhh
    @ahmedrhh 7 років тому

    I have done what you said, but if i continue like this that means i will create a php file for each post is that right?
    and is there another way not to do that.

  • @lthawkeye5512
    @lthawkeye5512 6 років тому

    Why wasn't config.php required in the navbar to use the ROOT_URL like in the index.php and post.php?

  • @alexandrufilipescu1301
    @alexandrufilipescu1301 6 років тому

    the $_GET['id'] from where gets its ID? from database or from index.php? thanks!

  • @carstenvilstrup2154
    @carstenvilstrup2154 7 років тому

    Thanks, have donated via pay pal

    • @TraversyMedia
      @TraversyMedia  7 років тому +4

      Thank you man. I REALLY appreciate it. More content coming and I won't disappoint you

  • @hazemhussien5618
    @hazemhussien5618 7 років тому

    really awesome man !
    do you have any good practises or other courses about php to do while im waiting for you to upload ?
    your course on udemy was really advanced so i had to quit

  • @Szasz18
    @Szasz18 5 років тому

    I have a question, guys. Every time I use bootswatch the background of the different boxes doesn`t appear. Like Post One and Post two has a grey box or the background of the navbar. For me, only the text appears and nothing else. Can you help me, please? Thank you!

    • @myster1ousdemon
      @myster1ousdemon 4 роки тому

      I think it's because they changed the bootstrap itself
      Years passed

  • @nasibullomukhamedov687
    @nasibullomukhamedov687 3 роки тому

    source code please, link is not working

  • @GMCrelan
    @GMCrelan 6 років тому

    11:57 how do you move the text?

    • @frantisek9413
      @frantisek9413 5 років тому

      tab

    • @joeyGunz1-w1r
      @joeyGunz1-w1r 5 років тому

      How do you move it left? Tab is right but if I hit backspace it deletes the text

  • @JoshuaGordon123
    @JoshuaGordon123 4 роки тому

    For anyone (like me) creating this database in SQL code:
    Create database:
    CREATE DATABASE phpblog;
    Switch to database:
    USE phpblog;
    Create table:
    CREATE TABLE post (
    id INT(11) AUTO_INCREMENT PRIMARY KEY,
    title VARCHAR(255) NOT NULL,
    body TEXT NOT NULL,
    author VARCHAR(255) NOT NULL,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
    );
    Add value to table:
    INSERT INTO post (title, body, author)
    VALUES (
    'Post One',
    'This is my very first post on this awesome blog',
    'Joshua'
    );

  • @rotimibest8530
    @rotimibest8530 7 років тому

    In building this website, did you use a specific MVC framework or its just pure php? Thanks

  • @michaeldalby1971
    @michaeldalby1971 7 років тому

    hi Brad, is it safe to put the user name and password for you database inside the html (doesn't this expose the details to anyone using the website)?.??... could you do a tutorial on security / logins and redirecting if user is unauthorised??

  • @DrazV2
    @DrazV2 5 років тому

    Did anybody else NOT get the config.php file working? It just messed up everything. We don't even require the file inside db.php but somehow Brad can call the DB_... we defined? I'm getting errors that those are already defined.

  • @successfulpeople
    @successfulpeople 6 років тому

    Can I select TEXT in place of VARCHAR? Thanks

  • @adam74332
    @adam74332 7 років тому

    Hi Brad, thanks for the video!
    One question, I'm getting, "Fatal error: Uncaught Error: Call to undefined function mysqli_fetch_all()" and "Stack trace: #0 {main} thrown" - code all looks the same, any idea what might be causing this? Thanks in advance.

  • @ranjeetmachale8986
    @ranjeetmachale8986 4 роки тому

    Like you did in your video in 7 mins 10 seconds that error when you change root to root1 eroor appears , it doesnt appear on mine and basically my whole thing is unresponsive , Please tell how to fix it

  • @michaeldalby1971
    @michaeldalby1971 7 років тому +1

    cool bean Brad.... thanks for the video

  • @patrasculucian2403
    @patrasculucian2403 6 років тому +9

    22:39 - The moment when you realize that this video should've been under 15 min

  • @markop7320
    @markop7320 5 років тому

    Can someone explain to me the part where he uses a link to send the parameter via URL.I mean wouldn't it be the same if he used

  • @caroldanvers265
    @caroldanvers265 6 років тому

    You're the best Brad! But for some reason my application doesn't like
    $id = $_GET['id']; It throws a variable undefined. Any ideas?

    • @circulardep
      @circulardep 6 років тому

      Perhaps it has to do with the query string that you inserted in the URL in the a-tag? Just a suggestion, I can be wrong

    • @TimGallant
      @TimGallant 5 років тому

      @@circulardep Your ID is probably in caps in the database. I wasn't returning the ID and I couldn't figure out why until is called ['ID'].

    • @faridulislam969
      @faridulislam969 4 роки тому

      I also unable to use id in single post.php it's says undefined variable

  • @saint1633
    @saint1633 6 років тому

    Thanks a lot. Clear explanation !

  • @NathanBudd
    @NathanBudd 6 років тому

    Why does db.php not require config.php to pass DB_NAME etc?

  • @valeryevs8060
    @valeryevs8060 5 років тому

    how to made for this limit list posts and pagination?

  • @jakub7048
    @jakub7048 6 років тому

    very good explanation Brad ! :)

  • @antidotejack2771
    @antidotejack2771 6 років тому

    I'm commenting a year later and everything works until the loop. the array is store in the variable but the loop doesn't work for me. Some body help!

  • @Bookshelfstorage
    @Bookshelfstorage 6 років тому +1

    The links to the bootswatch.com CSS files you keep using in this series no longer work. And you should probably be using something besides the default class because it's not producing the desired results. Primary might be a better choice.

  • @РоманЖежель-й2ц
    @РоманЖежель-й2ц 7 років тому

    Awesome, but why don't use php 7.1 and PDO?

    • @TraversyMedia
      @TraversyMedia  7 років тому +6

      I will eventually get to PDO. I want to cover both. I will also do a MySQLi OOP video

  • @louisbertini6840
    @louisbertini6840 5 років тому

    Fatal error: Uncaught Error: Call to undefined function mysqli_fetch_all()
    Mysqli fetch all doesn't work with my sever. Does anyone have another method they can share?

  • @andrewterry9531
    @andrewterry9531 6 років тому

    I am keep getting an error at
    $post = mysqli_fetch_assoc($result);
    Fatal error: Call to undefined function mysqli_fetch_all() in index.php on line 12
    Any ideas Brad?

    • @dougmoen
      @dougmoen 6 років тому

      Me too. try $posts = mysqli_fetch_array($result, MYSQLI_ASSOC); as a starting point. worked for me.

  • @ibraheema.rekany9641
    @ibraheema.rekany9641 2 роки тому

    1) 00:38 .

  • @jamesfarrer8289
    @jamesfarrer8289 7 років тому

    Hi Do you have the source code here so I can test?

  • @joey546
    @joey546 7 років тому

    Did you make that chrome start screen yourself?

    • @TraversyMedia
      @TraversyMedia  7 років тому +2

      No it is an extension called Momentum

    • @joey546
      @joey546 7 років тому

      ahh okay, thanks.

  • @josipbrnelic5914
    @josipbrnelic5914 5 років тому

    I don't get the part where you use $_GET['id']...How does the id end up there?

    • @BRIAN21552
      @BRIAN21552 5 років тому

      iam getting an error 2

  • @hansr137
    @hansr137 5 років тому

    Hey, I keep getting an error when I'm trying to var_dump(), as the result I get is "NULL".
    I think it's because I get this error: mysqli_real_connect(): (HY000/1045): Access denied for user 'pma'@'localhost' (using password: NO)
    Anyone have any experience dealing with this? :/

  • @muhammadroshaan841
    @muhammadroshaan841 7 років тому

    please upload next part :) thanks !!

  • @FranchGraphics
    @FranchGraphics 5 років тому

    wow. helped me a ton!

  • @tarcisiousnjagi9933
    @tarcisiousnjagi9933 2 роки тому

    nice one

  • @nicolaikurtos5685
    @nicolaikurtos5685 6 років тому

    var_dump($posts); won't do anything ...

  • @LatinoWebStudio
    @LatinoWebStudio 3 роки тому

    Thanks for the video! At minute 9:00 you mention a SQL beginner to intermediate series but I didn't see it get linked. I've found these two videos from you but want to double-check to see if they're the correct series you're referring to in the video.
    ua-cam.com/video/9ylj9NR0Lcg/v-deo.html&ab_channel=TraversyMedia
    ua-cam.com/video/nWeW3sCmD2k/v-deo.html&ab_channel=TraversyMedia
    If those aren't it, which is the link to the MYSQL video series that you're referring to?

  • @FreakyCoach
    @FreakyCoach 7 років тому

    Thank you

  • @theblackbanana
    @theblackbanana 7 років тому +3

    WTH at 6:40 cracked me up

  • @kushalchavan1
    @kushalchavan1 7 років тому +1

    please upload php codeigniter parts

    • @TraversyMedia
      @TraversyMedia  7 років тому +2

      I'm working on it. Should be soon

    • @arioseno8320
      @arioseno8320 7 років тому

      Kushal Chavan hey people still use CI? laravel is better imho

    • @TraversyMedia
      @TraversyMedia  7 років тому +1

      Yeah I think so. I think CI is a great framework to learn the basics of MVC. Laravel is better though in my opinion

    • @olami7557
      @olami7557 7 років тому

      Traversy Media I actually built an administrative part for the blog but I was wondering how do I actually prevent users from navigating to the admin part of the application. Thanks in advance

  • @joshuapenamante3026
    @joshuapenamante3026 7 років тому

    it helps alot

  • @donmbelembe1089
    @donmbelembe1089 7 років тому

    Mysqli is deprecated. in the latest version of PHP it's showing a alert message that Mysqli is going to be removed soon

  • @Horoe
    @Horoe 4 роки тому

    this was very confusing I had no idead what is going on

    • @noahmalchy2676
      @noahmalchy2676 4 роки тому

      check out his tutorials on just mysql first then come back

  • @Yash42189
    @Yash42189 4 роки тому

    I feel dumb, man. Do you all understand what all of this means?
    $result = mysqli_query($conn, $query);
    $posts = mysqli_fetch_all($result, MYSQLI_ASSOC);
    mysqli_free_result($result);

    • @Yash42189
      @Yash42189 4 роки тому

      I guess I'm not really sure what the functional difference between mysql_query and mysql_fetch is?

    • @Yash42189
      @Yash42189 4 роки тому

      Okay I managed to add a delete post button from by myself. I think im starting to understand

  • @EhSUN37
    @EhSUN37 6 років тому

    you are not teaching a language you are just using some functions in a programming language without explaining them properly .

    • @circulardep
      @circulardep 6 років тому

      In my opinion, you can't expect someone to teach you all the ins and outs of a language for free. It would be very rare to find such a thing. And that's quite normal actually, these developers are people who need to earn money for a living, so it just can't be all for free.
      I guess there are paid courses that will teach you that in depth. Brad has done more than enough giving you the core fundamentals of PHP, then it's up to you to develop your PHP skills either by looking at the documentation or enrolling in some paid course.

  • @sajaobaidat7133
    @sajaobaidat7133 3 роки тому

    thank you