Show comment message from the database - PHP tutorial

แชร์
ฝัง
  • เผยแพร่เมื่อ 11 พ.ย. 2024

ความคิดเห็น • 237

  • @turboromy
    @turboromy 8 ปีที่แล้ว

    I didn't know what php was only a few weeks ago and I wanted to make a site where multiple user makes multiple inputs and they get result after "computer" analyze and returns it. "Computer" would be a server, now I know. What I learned from your tutorial taught it can be done with php and I got quite happy today. Thanks.

  • @SoccerEFM
    @SoccerEFM 7 ปีที่แล้ว +1

    I've been searching for this sooo long, thanks for your awesome tutorials and explanation!!
    it seems like there are a very low ammount of php tutorials in comparison to other programming languages

  • @pilotflyingapp6753
    @pilotflyingapp6753 4 ปีที่แล้ว +1

    easy and nice explanation! thank you!
    the only thing is missing I believe is when we comment it should get the new comments on top and older comments below.. (the order of comments should be new to older)

    • @mutalemulenga8708
      @mutalemulenga8708 4 ปีที่แล้ว +1

      in your select statement, add ORDER BY uid DESC.

    • @khalidrashid282
      @khalidrashid282 4 ปีที่แล้ว +1

      It works! Thanks

    • @ignitestudiox3629
      @ignitestudiox3629 3 ปีที่แล้ว

      Interesting but can you tell me where to place it in that area or where it needs to be next to please thank you

  • @robertbeauchamp6760
    @robertbeauchamp6760 7 ปีที่แล้ว +5

    I want to thank you for the tutorial, my client wanted to add a comment system last minute to his website and this helped alot. However, now he wants to add a reply option to the comments that are posted. I wanted to know how I will be able to do that since I didnt see that option in the tutorial. thank you again for your help.

  • @chrisjacobs3360
    @chrisjacobs3360 5 ปีที่แล้ว

    Nice one. Works really well. Keep up the work buddy.

  • @cyronadebz8700
    @cyronadebz8700 4 ปีที่แล้ว

    Thank you so much mtuts. I love your work... Well explained

  • @moviesregencyrecap
    @moviesregencyrecap 2 ปีที่แล้ว

    text just going straight i already add .

  • @dougyhardy356
    @dougyhardy356 4 ปีที่แล้ว

    Thankyou Dani for these great tuts

  • @nelsirc9152
    @nelsirc9152 6 ปีที่แล้ว +1

    I love your tutorials.. thank you very much.!. you're really great.. God Bless you.. :)

  • @eliottdonatien1519
    @eliottdonatien1519 6 ปีที่แล้ว

    I am learning a lot with your videos thanks man !

  • @Zealot02
    @Zealot02 2 ปีที่แล้ว

    Thank you very much !

  • @cyrisful
    @cyrisful 7 ปีที่แล้ว +2

    Notice: Undefined variable: result in C:\xampp\htdocs\commentsec\comments.inc.php on line 16
    Fatal error: Call to a member function fetch_assoc() on null in C:\xampp\htdocs\commentsec\comments.inc.php on line 16
    thats the error I am getting after i got the typo corrected, right now the getComments function is this
    unction getComments($conn){
    $sql = "SELECT * FROM comments ORDER BY cid DECS";
    $results = $conn->query($sql);
    $row = $result->fetch_assoc();
    echo $row['message'];
    }
    also can you help in regards on how to stop the duplication of entries if and when i refresh the page, I did go through the comments below to check if others were facing the same issue, but was not able to understand how they solved it.
    Thanks !!

    • @triggerwarnussy
      @triggerwarnussy 5 หลายเดือนก่อน

      I resolved it by changing a bunch of stuff, here's my comments.inc.php file:

  • @juancarlosdomingo4991
    @juancarlosdomingo4991 6 ปีที่แล้ว +3

    Where's the next tutorial video after this video?

  • @MehediHasan-zi2yg
    @MehediHasan-zi2yg 5 ปีที่แล้ว

    Thanks so much mate!! nice tutorial, really helped a lot

  • @crocsocial3728
    @crocsocial3728 8 ปีที่แล้ว +11

    mmtuts, when ever I refresh my page it copy's my previews comment and pastes it so it creates a clone and in the data base aswell, help please.

    • @Indestructiblegamerz
      @Indestructiblegamerz 8 ปีที่แล้ว +1

      me too wtf

    • @alsehalo6113
      @alsehalo6113 7 ปีที่แล้ว

      i have the same problem

    • @a2p75
      @a2p75 7 ปีที่แล้ว

      Does it ask you permission to resend?
      If it does AND you click 'resend' it literally reruns the sql INSERT query. Instead click on the URL and press ENTER. That way the page is revisited and NOT rerun.
      I don't know how to solve it yet, maybe by 'emtying' the $variable sql after running the query but I haven't tried that yet. Hope it helps.

    • @Indestructiblegamerz
      @Indestructiblegamerz 7 ปีที่แล้ว +7

      I just used the php header command to send the user back to the same page after they submit the comment. This way, they technically aren't just reloading the page, but it has the same effects of reloading, except it doesn't resubmit the comment. Fixed. If you need help just reply and I'll help when I see it.

    • @tyle1288
      @tyle1288 7 ปีที่แล้ว +5

      At the end of the setComments function add:
      header("Location: ./index.php");

  • @deezee1414
    @deezee1414 7 ปีที่แล้ว

    from a forum "NEVER put $_POST or $_GET data directly into a query, it can be very harmful if someone seeks to exploit your mistake." - Is there another way to do this, than what you have been teaching us these last 7 episodes?

  • @nujood3423
    @nujood3423 6 ปีที่แล้ว

    Great job. thank you so much sir

  • @gloriabukachi1
    @gloriabukachi1 6 ปีที่แล้ว +4

    while(loop){
    functions
    }
    exit(); # put this to avoid repeat display of data when you refresh page
    }

    • @Leon-zo2wj
      @Leon-zo2wj 6 ปีที่แล้ว +1

      Thank u for ur help mate, rly appreciate it, worked for me

    • @gloriabukachi1
      @gloriabukachi1 6 ปีที่แล้ว

      you are welcome @@Leon-zo2wj

    • @gloriabukachi1
      @gloriabukachi1 6 ปีที่แล้ว

      where are you from? @@Leon-zo2wj

    • @vijaykanth2009
      @vijaykanth2009 5 ปีที่แล้ว +1

      Not working

    • @k-lo-kpromo
      @k-lo-kpromo 5 ปีที่แล้ว

      where do you input string thou

  • @vojka2973
    @vojka2973 7 ปีที่แล้ว

    Great teacher

  • @grizzly9180
    @grizzly9180 5 ปีที่แล้ว

    Great tutorial, great accent

  • @AbhikShrestha
    @AbhikShrestha 6 ปีที่แล้ว +1

    Hey, how come I can't call the getComments functon?
    Call to undefined function getComments();

  • @diviiniity6529
    @diviiniity6529 8 ปีที่แล้ว +1

    At 4:00, you wrote
    $row = $result->fetch_assoc();
    Is that good or should it be changed to
    $row = mysqli_fetch_assoc($result);
    like we have in the other tutorials?

  • @diyandy3172
    @diyandy3172 6 ปีที่แล้ว

    Hey mmtuts, great video and it's helped me out quite a lot. So I'm trying to comment on various articles. So each comment has to relate to the specific article it's intended for. All articles are in db. My comments table has the articleID as well as comment,id,user. The problem I have is that I only seem to able to output the last comment submitted. Previous comments stay in db but only last one displays. Not sure if I have to do INNER JOIN or something? Any suggestions would be great. Thanks. Andy.

  • @mackynikat8833
    @mackynikat8833 3 ปีที่แล้ว

    This one is not working on my wonderful creation. everytime i display the comments from my database inside a div, it will only display the latest. and it's insane.

  • @daniellajohansson
    @daniellajohansson 7 ปีที่แล้ว

    Thanks... works great.

  • @navaarunbhattacherjee4511
    @navaarunbhattacherjee4511 6 ปีที่แล้ว

    I just don't understand one thing here! The 'message' variable ($message = $_POST['message']) was declared inside the 'setComments' function, but how the 'getComments' function got access to it (which was outside of the 'setComments' function) with '$row['message']' & showing the result without any error?

  • @1811can
    @1811can 4 ปีที่แล้ว +1

    when i change the order of these 2 functions i get Call to undefined function getComments() error but there is nothing to cause this error between 2 functions

  • @mackynikat8833
    @mackynikat8833 3 ปีที่แล้ว

    Hey buddy is this on the background or we need to refresh the page to display it

  • @carolinezamora2389
    @carolinezamora2389 8 ปีที่แล้ว +7

    if you have this error: $row = $result->fectch_assoc();
    Try this if php I think: $row = mysqli_fetch_assoc($result);

    • @lilvc3469
      @lilvc3469 6 ปีที่แล้ว

      Yup

    • @gloriabukachi1
      @gloriabukachi1 6 ปีที่แล้ว

      i see spelling error too

    • @filipefilm8218
      @filipefilm8218 5 ปีที่แล้ว

      Life savior

    • @becreative7072
      @becreative7072 5 ปีที่แล้ว

      now it is while($row=mysql_fetch_array or assoc($result)){}

    • @Ramaihaholic
      @Ramaihaholic 4 ปีที่แล้ว

      hi can any of you help? i did exactly what he did but on my website it gives me this error:
      Parse error: syntax error, unexpected 'getComments' (T_STRING), expecting ',' or ';' in C:\xampp\htdocs\website tester\index.php on line 31
      this is my code if you want to check it out...
      thanks in advance
      comments.inc.php:

  • @abtahitajwar7419
    @abtahitajwar7419 7 ปีที่แล้ว +1

    I'm facing a serious problem
    When I'm reloading my comments that I've written before are saving into my database. Its happening if I leave my comment box empty and reload my page. What should I do now??

  • @eligilbert7752
    @eligilbert7752 2 ปีที่แล้ว

    I've been having the problem of comments being endlessly duplicated when I reload. I could use some help.

  • @AnimatedAzterkGT
    @AnimatedAzterkGT 5 ปีที่แล้ว

    mmtuts do you have any mistake? i can't see the annotations anymore please help me

  • @johnmartininfante3754
    @johnmartininfante3754 7 ปีที่แล้ว +1

    sir??
    can i have a question? why does my database comments go beyond the comment-box??

  • @annaheilos295
    @annaheilos295 4 ปีที่แล้ว

    Hey, iknow I´m really late to ask a question, but maby it will work :) i love you tutorial and everthing worked fine until the very last step:
    despite the use of nl2br (and also nl2br(stripslashes) and nl2br(stripcslashes), the comments shown on the website exceeds the white text box. Only of i press Enter while writing the comment, it works. Do you have any idea what i did wrong?

  • @blackwins7397
    @blackwins7397 4 ปีที่แล้ว +1

    how can you make comment on a comment? , like what we have on yt comment here

  • @moogwilliams5071
    @moogwilliams5071 5 ปีที่แล้ว +2

    My comments wont show up in myphpadmin, everything seems to be working, no errors, but the messeges dont show

    • @moogwilliams5071
      @moogwilliams5071 5 ปีที่แล้ว +2

      got it working, ask me if you have the same problem :D

    • @adamjones6473
      @adamjones6473 5 ปีที่แล้ว

      @@moogwilliams5071 hey man, could you tell me how you fixed it?

    • @adamjones6473
      @adamjones6473 5 ปีที่แล้ว

      @@moogwilliams5071 Bruh I'm still stuck, do you have the fix?

    • @moogwilliams5071
      @moogwilliams5071 5 ปีที่แล้ว

      @@adamjones6473 sorry, it's been a while and it's really late, I'll search for what it was and get back to you as soon as I find it 😁

    • @adamjones6473
      @adamjones6473 5 ปีที่แล้ว

      @@moogwilliams5071 I think I found out what my problem was lol, it was just a small typo. I wasn't getting any errors so it was just a matter of stumbling across it.

  • @charlievm2597
    @charlievm2597 3 ปีที่แล้ว

    Please help man, Ik its a old video and all, but whenever I refresh page, the comments multiply, by 2. Please help.

  • @dinukakumara4944
    @dinukakumara4944 3 ปีที่แล้ว

    The teaching is very good.But When I refresh the page , it will ask about a form resubmission.And when I click continue , The previous comment duplicates and displays
    Is there a solution for it pls?

  • @fanitram
    @fanitram 5 ปีที่แล้ว +1

    hi, I have this error:Uncaught Error: Call to a member function fetch_assoc() on bool in comments.inc.php: while ($row = $result->fetch_assoc()) {
    and index.php: getComments($conn);
    what could this be? I have checked for typos

    • @stellathemistokleous8071
      @stellathemistokleous8071 4 ปีที่แล้ว

      i have the same problem. did you find the solution?

    • @fanitram
      @fanitram 4 ปีที่แล้ว

      @@stellathemistokleous8071 no

    • @triggerwarnussy
      @triggerwarnussy 5 หลายเดือนก่อน

      I resolved it, at least for myself! here's my entire comments.inc.php file:

  • @MeninodeValpoi
    @MeninodeValpoi 3 ปีที่แล้ว

    I certainly need to hear an answer from you Sir. Wonderful tutorial, when I practised on my machine, in my localhost, I deleted all the comments from the database, but every time I use the url to open it up, the comments keep on multiplying in the table (database). Even if I refresh the browser, the same comment gets added in the table again WHY? Can you please help me if you know why this is happening? WAITING FOR YOUR REPLY SIR. Need it please let me know.

    • @ignitestudiox3629
      @ignitestudiox3629 3 ปีที่แล้ว

      The reason that happens is because when we refresh the screen you're basically turning the URL to repost to its last comment displayed even if you delete everything in the database it will still show up because the database needs to be dropped and reinstall but that will only clear the screen of comments once you enter any other comments it will be listed in the database and then displayed on the comment section if you refresh it after that he will display it once again it's not a common session like Instagram or TH-cam it's a common section for one particular picture video or display for the user to comment on
      so I think that's how that works but I am now 100% sure that's just what I notice for myself when experimenting with this particular code entry

  • @brzjason
    @brzjason 6 ปีที่แล้ว +1

    hello, my comments are dupplicating in the database as well as in the front page..how do I solve that?

  • @debarghamukherjee666
    @debarghamukherjee666 4 ปีที่แล้ว

    Comment neither getting inserted into database nor showing up when writing through Android phone but everything works fine in my pc browser!!!Can anyone suggest me what's wrong?

  • @elijahwalker8103
    @elijahwalker8103 2 ปีที่แล้ว

    I keep getting this error mysqli::query(): Couldn't fetch mysqli also getting it when i try to send a comment to my DB

  • @zmajnex011
    @zmajnex011 8 ปีที่แล้ว

    Hi there, great tutorilas for beginners. I was wondering how can you protect your comment section from html tags?
    Example: if i write comment like this some comments it will write a bold comment or even worse maybe someone could insert malicious code through our comment form.How to protect our comment form?

    • @Dani_Krossing
      @Dani_Krossing  8 ปีที่แล้ว

      A few episodes ahead of this one I show exactly that ;)

    • @zmajnex011
      @zmajnex011 8 ปีที่แล้ว

      Founded, thanks for express answer

    • @Gonzalezx600
      @Gonzalezx600 8 ปีที่แล้ว

      What episode is that? I cant find it?

    • @Dani_Krossing
      @Dani_Krossing  8 ปีที่แล้ว

      th-cam.com/video/Qt9W6U3msOk/w-d-xo.html

    • @assamesedictionary2606
      @assamesedictionary2606 6 ปีที่แล้ว

      Hi this link shows nothing. Please check it. BTW I am unable to call the get_comments function.

  • @xito7271
    @xito7271 8 ปีที่แล้ว

    Almost everything works. I can insert comments into the database but it doesn't echo out the comments? Could you help?

  • @ltulip9297
    @ltulip9297 8 ปีที่แล้ว

    Hi ,mmtuts, I have a question. You used php+mysql to make a comment section. There is another way to make a comment section ,that is JavaScript+Ajax. Do you know the difference between these two methods? Thank you ,I am just a little confused about this.

    • @Dani_Krossing
      @Dani_Krossing  8 ปีที่แล้ว

      Hi there :) Using JavaScript and Ajax isn't really another way of making a comment section, but rather a "upgraded" way of doing it. Ajax is a combination of using JavaScript and PHP in a way that doesn't require the user to refresh the browser each time they (as an example) post something in the comment section. It is simply a way to run PHP code on "part" of the website, whenever you interact with a database which allow for a smoother looking experience.

    • @ltulip9297
      @ltulip9297 8 ปีที่แล้ว

      Now I know that ,thank you.Are you willing to do a AJAX tutorial?

    • @Dani_Krossing
      @Dani_Krossing  8 ปีที่แล้ว

      I plan to do it in the future :)

    • @ltulip9297
      @ltulip9297 8 ปีที่แล้ว

      I can't wait for your new tutorials!Thank you for all the tutorials you have done!

  • @mattnilsen1199
    @mattnilsen1199 7 ปีที่แล้ว

    Hi mmtuts, i did not use the tag, but why isnt my body tag in css change the background-color:#ddd ?

    • @jesusconstancio8777
      @jesusconstancio8777 7 ปีที่แล้ว

      I'm also having the same issue, did anyone ever find the fix?

  • @daz231181
    @daz231181 8 ปีที่แล้ว

    Hiya mate, me again. Just wondering how I get it to post the users name with the comment as right now it post the work 'uid' not sure if i messed up somewhere. Thanks again for the tutorials

  • @asdfg1346on
    @asdfg1346on ปีที่แล้ว

    If you Write $con variable as parametter inside the set comments and Get comments function How does it kmow Where to get the Con variable from because he dident include the file

    • @triggerwarnussy
      @triggerwarnussy 5 หลายเดือนก่อน

      hi here is my entire comments.inc.php file which corrects these errors and worked for me:

  • @primedesigns6046
    @primedesigns6046 7 ปีที่แล้ว

    Love your tutorials so much man, I have a question though. How does TH-cam make it so when you post a comment you see it pop up on the screen but the page doesn't visibly reload?

    • @Dani_Krossing
      @Dani_Krossing  7 ปีที่แล้ว +2

      Each time a website interacts with a database it needs to refresh the page somehow, like when we post comments on TH-cam.
      I'm not sure which method exactly TH-cam uses, but one of the ways to interact with databases WITHOUT needing to refresh the entire page, is to use Ajax. What Ajax does, is to only refresh part of the page, meaning that we can reload a single HTML element in our page (which contain all the comments under a video on TH-cam as an example) without reloading the entire page.
      Ajax is a method where you use PHP and JavaScript (or jQuery), in order to refresh specific content without reloading a page.
      Here is a link: www.w3schools.com/js/js_ajax_intro.asp

  • @PikatchuVk
    @PikatchuVk 6 ปีที่แล้ว

    setComments doesn't work ? when I use it, nothing is printed

  • @sirahmed6562
    @sirahmed6562 7 ปีที่แล้ว

    Thanks so much teacher i have tell your channel all my friends.. please can you made videos for mvc 5 or phyton please if you can thank you so much a lot

  • @MortgageBrokerLondonOntario
    @MortgageBrokerLondonOntario 6 ปีที่แล้ว

    I keep getting "Uncaught Error: Call to a member function query() on null in ...coments.inc.php: 10 Stack trace: #0.... setComments(NULL)#1main thrown in... on line 10 - Any ideas?

    • @sanishehzadi1
      @sanishehzadi1 6 ปีที่แล้ว

      Add this after form:
      require 'comments.inc.php';
      getcomments($conn);

  • @k-lo-kpromo
    @k-lo-kpromo 5 ปีที่แล้ว

    great video... but how do you stop duplicate of data submitted on refresh

  • @wesleymacinnis7506
    @wesleymacinnis7506 8 ปีที่แล้ว

    My text is spilling out of the white background we set for individual comments. Thoughts as to why?
    Thanks,
    Wes

  • @user-ik2by4ml8d
    @user-ik2by4ml8d 7 ปีที่แล้ว

    Not sure if your still replying but I'm wondering how to change it from showing the oldest comments at the very top to the newest ones, I've googled a bit and can't seem to find what I'm looking for but I can guess its got to do with the cid number etc just not sure how to write it.

    • @Dani_Krossing
      @Dani_Krossing  7 ปีที่แล้ว +1

      To do this you need to change the select statement in getComments() from "SELECT * FROM comments" to "SELECT * FROM comments ORDER BY cid ASC"

  • @mano2012ful
    @mano2012ful 7 ปีที่แล้ว

    awesome man

  • @J_yung_
    @J_yung_ 6 ปีที่แล้ว

    which one is the previous episode before this?

  • @mnunez6153
    @mnunez6153 4 ปีที่แล้ว

    how to change the order of comment from top the latest ?...

  • @ViktorHilmer
    @ViktorHilmer 7 ปีที่แล้ว

    Hi, I would like to ask if you know where is the problem in my code, I would like to change the date format to dd-mm-yy. So my code looked like .date('d-m-Y H:i:s'). but when i hit the submit button, the message doesn't even save to my database.

    • @Dani_Krossing
      @Dani_Krossing  7 ปีที่แล้ว +1

      The SQL DATETIME format NEEDS to have the format as YYYY-MM-DD HH:MI:SS when you insert it into the database. It is a standard you can't change with DATETIME. If you want to change the format to dd-mm-yy, then you need to do it when you pull the data out from the database instead.
      Here is a link that shows some of the different SQL date formats: www.w3schools.com/sql/sql_dates.asp

    • @ViktorHilmer
      @ViktorHilmer 7 ปีที่แล้ว

      Thank you very much for a quick respond!

  • @mattnilsen1199
    @mattnilsen1199 7 ปีที่แล้ว

    Hi again
    just another question on this tutorial as i am learning php, in the comments.inc.php file should we always close off our php tags as i noticed its not

    • @Dani_Krossing
      @Dani_Krossing  7 ปีที่แล้ว +1

      If your document ONLY contains PHP code, then it is better to not close the PHP tags at the end because it doesn't have a purpose. Only close the PHP tag if you have another type of code coming right after.

    • @mattnilsen1199
      @mattnilsen1199 7 ปีที่แล้ว

      Ok cool thankyou very much i wasnt aware of this

  • @plexodus1435
    @plexodus1435 8 ปีที่แล้ว

    Hi mmtuts, How do I make it so that a new comment gets added on top not at the bottom of all the comments?

    • @lohanson5408
      @lohanson5408 7 ปีที่แล้ว

      use sql statement "order by" keyword ,
      $sql = "SELECT * FROM comments order by cid desc";

  • @noureenaraza6159
    @noureenaraza6159 8 ปีที่แล้ว

    everything works. I can insert comments into the database but it doesn't echo out the comments?

  • @nahumg1
    @nahumg1 7 ปีที่แล้ว

    Why the select statement of "SELECT * FROM comments" doesn't selects all the database instead of the first row?

    • @Dani_Krossing
      @Dani_Krossing  7 ปีที่แล้ว +2

      It does select all database results, however in order to get them from your SQL code to the website, you need to loop the results and spit them out individually using PHP.

    • @nahumg1
      @nahumg1 7 ปีที่แล้ว

      First of all thank you for the quick answer!
      Second of all, the "mysqli_fetch_assoc" spits only the top row that wasn't already selected?

  • @iosmayank
    @iosmayank 8 ปีที่แล้ว

    thanks for the tutorial ....Could you please provide these php files link too in your tut description ????

  • @zou070
    @zou070 7 ปีที่แล้ว +2

    when I refresh the browser my comments are cloning. I'm writing for example: qwerty and when I refresh I have 2 comments qwerty. PLS help.

    • @a2p75
      @a2p75 7 ปีที่แล้ว +1

      Does it ask you permission to resend?
      If it does AND you click 'resend' it literally reruns the sql INSERT
      query. Instead click on the URL and press ENTER. That way the page is
      revisited and NOT rerun.
      I don't know how to solve it yet, maybe by 'emtying' the $variable sql
      after running the query but I haven't tried that yet. Hope it helps.

    • @Indestructiblegamerz
      @Indestructiblegamerz 7 ปีที่แล้ว

      I just used the php header command to send the user back to the same page after they submit the comment. This way, they technically aren't just reloading the page, but it has the same effects of reloading, except it doesn't resubmit the comment. Fixed. If you need help just reply and I'll help when I see it.

    • @growwithdesign
      @growwithdesign 7 ปีที่แล้ว

      I still cannot get this fixed. Can you create a codepen for this? Also, i'm trying to submit comments by using AJAX. I don't want to reload the page every time a comment is typed.

    • @vetonm3680
      @vetonm3680 6 ปีที่แล้ว

      I used the same technique but it shows an error " Cannot modify header information - headers already sent by.... "

  • @stellathemistokleous8071
    @stellathemistokleous8071 4 ปีที่แล้ว

    hello i have this error Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, bool given in C:\xampp\htdocs\php\KitchenStories\comments.inc.php on line 17. can you help me?

    • @triggerwarnussy
      @triggerwarnussy 5 หลายเดือนก่อน

      I changed a bunch of stuff in my comments.inc.php file and it resolve the fetch_assoc issue, here's my entire file:

  • @deezee1414
    @deezee1414 7 ปีที่แล้ว

    Hey mm, don't know how fast you can answer this, but for me when I have the second function in my php file, it suddenly stops working (?) I can setComments, but I cannot getComments, as whenever I try to actually have that function inside my PHP file, my website just doesn't want to open anymore (?)

    • @deezee1414
      @deezee1414 7 ปีที่แล้ว

      my code: function getComments($conn) {
      $sql = "SELECT * FROM comments";
      $result = mysqli_query($conn, $sql);
      $row = $result->fetch_assoc();
      echo "$row['c_message']";
      }

    • @Dani_Krossing
      @Dani_Krossing  7 ปีที่แล้ว

      Deezee It sounds like you forgot to close a statement or a line of code in your setComments.

    • @Dani_Krossing
      @Dani_Krossing  7 ปีที่แล้ว

      Deezee I noticed you haven't fixed the corrections I placed in the video annotation. Try turning on the annotations and watch the part where we create the setComments function again :)

    • @deezee1414
      @deezee1414 7 ปีที่แล้ว

      Ok, thank you :D

    • @deezee1414
      @deezee1414 7 ปีที่แล้ว

      Rewatched it , but couldn't find the annotation (?)

  • @abigaelarellano4644
    @abigaelarellano4644 8 ปีที่แล้ว

    I used your code for posting updates. What if I want to display only 3 updates and not all the updates in the database? I 'm sorry for my question, I'm not that good at coding actually.

    • @Dani_Krossing
      @Dani_Krossing  8 ปีที่แล้ว

      Just add LIMIT 3 at the end of the SQL select statement ;)

    • @abigaelarellano4644
      @abigaelarellano4644 8 ปีที่แล้ว

      hahaha. Thank you :)

  • @ianChrist11
    @ianChrist11 7 ปีที่แล้ว

    it wont show the comments below..

  • @oliverkirkpatrick1231
    @oliverkirkpatrick1231 7 ปีที่แล้ว

    It worked until i got up to echoing out the results onto my page and then it wouldnt upload any comments

  • @ivicahpps
    @ivicahpps 7 ปีที่แล้ว

    How can I show different comments on different pages? If anybody knows please help me!

  • @maxbleib
    @maxbleib 6 ปีที่แล้ว +1

    For everyone with issues about cloned comments after refreshing, do this:
    Go to your comment.inc.php and index.php files and add ob_start(); right after

  • @kaiqin5224
    @kaiqin5224 6 ปีที่แล้ว

    So currently if one were to put a single quote ' in the comment box it will not post. Been looking into prepared statements for this anyone else solve this issue so far though?

  • @kimgriffith7490
    @kimgriffith7490 8 ปีที่แล้ว

    Hello :)
    I changed your code to from $row = $result->fetch_assoc(); which gave me a fatal error message to $row = mysqli_fetch_assoc($result); and got a warning message instead:
    Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in /Applications/XAMPP/xamppfiles/htdocs/comments/comments.inc.php on line 17
    Could you please tell me how to fix this problem?

    • @kimgriffith7490
      @kimgriffith7490 8 ปีที่แล้ว

      Oh wait nevermind I got it... I thought your SELECT * FROM was SELECT + FROM... fixed it
      Great tutorials by the way!

    • @alexklepov5837
      @alexklepov5837 4 ปีที่แล้ว

      @Filmon Az Hello, i copied your code, but still facing error: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, bool given in. Help please, idk what to do

    • @alexklepov5837
      @alexklepov5837 4 ปีที่แล้ว

      @Filmon Az ахаха, по уровню английского понял?) Я уже нашел ошибку, переменная conn была использоваан дважды. Спасибо за отзывчивость))

    • @triggerwarnussy
      @triggerwarnussy 5 หลายเดือนก่อน

      in 2024 this worked for me, here's my entire comments.inc.php file:

  • @demona625
    @demona625 5 ปีที่แล้ว

    Guys i have a problem. I haven't got any error but database doesn't read my comments.

  • @kaiqin5224
    @kaiqin5224 6 ปีที่แล้ว

    anyone notice that the box won't accept apostrophe's? how would one fix this?

  • @clivechulan4777
    @clivechulan4777 7 ปีที่แล้ว

    Any one had this problem? - once the comment as been made if its a long one it spills over the comment box! I know its stated about 3mths ago but he didn't say how he fixed it.
    Any help here would be great. Thanks.

    • @clivechulan4777
      @clivechulan4777 7 ปีที่แล้ว

      Sorted I needed to type a sentence. Not just random letters to test it....lol

  • @k-lo-kpromo
    @k-lo-kpromo 5 ปีที่แล้ว

    everything works great but when i upload comments for my database info
    :Anonymous2019-09-19 18:23:18message" not the comments input...can you help me make the correction

  • @turboromy
    @turboromy 8 ปีที่แล้ว

    Does anyone else have CSS not applying to Chrome, but works on IE ? Also.... when I refresh browser, I get to see a pop up saying "confirm form resubmission....", and I'm curious what part of the code is calling this.

    • @turboromy
      @turboromy 8 ปีที่แล้ว

      Strangely, Chrome did update after a while.

    • @wilsongaturu134
      @wilsongaturu134 8 ปีที่แล้ว

      In Chrome right click and Go to Inspect element>Network>check Disable Cache.

  • @hellafresh4520
    @hellafresh4520 8 ปีที่แล้ว

    How do you display multiple videos with comments boxes under each videos?

    • @Dani_Krossing
      @Dani_Krossing  8 ปีที่แล้ว

      You just need to loop out the videos with one of the loops we have learned about. Then just include the or video tag inside the loop.
      If you are using s then make sure you include the link and video number in the database.
      if you are gonna use videos that are uploaded to your server then I would name each video the following:
      vid-category-number.mp4
      where you change category and number depending on your need.

    • @hellafresh4520
      @hellafresh4520 8 ปีที่แล้ว

      Does that go for the comment box too or do we have to make individual tables for each of the comment boxes?

    • @Dani_Krossing
      @Dani_Krossing  8 ปีที่แล้ว

      +Denny Feng
      You need to make a separate table for the videos, but also include 2 new columns to the comments table that says which video category and video number it belongs to.

    • @omidabbasi5385
      @omidabbasi5385 7 ปีที่แล้ว

      mmtuts

  • @Some_Techie
    @Some_Techie 6 ปีที่แล้ว +1

    How Am I able to make the newest comments first?

    • @SnicondoesCode
      @SnicondoesCode 6 ปีที่แล้ว +1

      Do like this: $sql = "SELECT * FROM comments ORDER BY date DESC";

    • @kaiqin5224
      @kaiqin5224 6 ปีที่แล้ว

      where did you put that though?

  • @bachienbeo
    @bachienbeo 8 ปีที่แล้ว

    When I refresh the website, the comment also refresh and it displays twice. So why ?

    • @Dani_Krossing
      @Dani_Krossing  8 ปีที่แล้ว +1

      You need to add exit(); at the end of your php script after the header(); to make sure it closes the script afterwards. I forgot to ad it in this video, but I mention it in a later episode.

    • @bachienbeo
      @bachienbeo 8 ปีที่แล้ว

      Haha.. Thanks very much from your quick response and your great tutorials.

    • @Dani_Krossing
      @Dani_Krossing  8 ปีที่แล้ว

      And thank you for watching :)

    • @netbooz9423
      @netbooz9423 8 ปีที่แล้ว

      In which tutorial you have add

    • @SurenderKumar-pb3wh
      @SurenderKumar-pb3wh 8 ปีที่แล้ว

      Modify your setComment function like this:
      function setComment($con) {
      if(isset($_POST['commentSubmit'])) {
      $user_id = $_POST['email'];
      $date = $_POST['date'];
      $message = $_POST['message'];
      $sql = "INSERT INTO comments (user_id, date, message)
      VALUES ('$user_id', '$date', '$message')";
      $result = mysqli_query($con, $sql);
      header("Location: dashboard.php");
      exit();
      }
      }

  • @oliverkirkpatrick1231
    @oliverkirkpatrick1231 7 ปีที่แล้ว

    I cant get it to take anything from the comment database but I can put things in it

  • @alsehalo6113
    @alsehalo6113 7 ปีที่แล้ว

    thanks alot , i have problem that each time i refresh the page the last comment is copied again to the data base ,

    • @alsehalo6113
      @alsehalo6113 7 ปีที่แล้ว

      header("Location: index.php");
      exit();--- i add this to the setComments($conn) function and now it is workiing

  • @maxbleib
    @maxbleib 6 ปีที่แล้ว

    if
    echo nl2br($row['messagel']);
    doset work, try
    echo nl2br(stripslashes($row['messagel']));
    or
    echo nl2br(stripsclashes($row['messagel']));

  • @funkerkv
    @funkerkv 7 ปีที่แล้ว

    Can someone tell me what this fatal error means??
    Fatal error: Call to a member function fetch_assoc() on boolean in C:\xampp\htdocs\comment_section\comments.inc.php on line 20

    • @triggerwarnussy
      @triggerwarnussy 5 หลายเดือนก่อน

      yes! here's my entire comments.inc.php file:

  • @julsdegs7280
    @julsdegs7280 8 ปีที่แล้ว

    hey man can you help me out please on how do i record time on database for example
    am_login
    am_logout
    pm_login
    pm_logout
    thanks cos im trying to make a daily time record and im only new in programming and i dont know what to do

  • @tobiasheide8866
    @tobiasheide8866 7 ปีที่แล้ว

    Hey fyr, måske kunne du lave et CMS SYSTEM :D

  • @netbooz9423
    @netbooz9423 8 ปีที่แล้ว

    Can you tell me how to view newly posted comment on top.

    • @Dani_Krossing
      @Dani_Krossing  8 ปีที่แล้ว

      Include "ORDER BY id ASC" at the end of your SQL statement.

    • @netbooz9423
      @netbooz9423 8 ปีที่แล้ว +1

      Thanks..
      After refresh the Index page the comment showing one more time .

    • @SurenderKumar-pb3wh
      @SurenderKumar-pb3wh 8 ปีที่แล้ว

      Modify your setComment function like this:
      function setComment($con) {
      if(isset($_POST['commentSubmit'])) {
      $user_id = $_POST['email'];
      $date = $_POST['date'];
      $message = $_POST['message'];
      $sql = "INSERT INTO comments (user_id, date, message)
      VALUES ('$user_id', '$date', '$message')";
      $result = mysqli_query($con, $sql);
      header("Location: dashboard.php");
      exit();
      }
      }

    • @diviiniity6529
      @diviiniity6529 8 ปีที่แล้ว

      AT the end of which SQL statement? I tried it in the SELECT statement inside the comments.inc.php, but it just messed up my code.

  • @abusaeed29
    @abusaeed29 7 ปีที่แล้ว

    how to make "show more" comment button... i want to limit the comments to show 10comments until i click "show more" button.

  • @brothersbyquad9941
    @brothersbyquad9941 7 ปีที่แล้ว

    Fatal error: Call to a member function fetch_assoc() on null

    • @Dani_Krossing
      @Dani_Krossing  7 ปีที่แล้ว

      It means that your SQL statement doesn't get any results from the database. So there is an error in your SQL code. Very likely because of a typo.

    • @triggerwarnussy
      @triggerwarnussy 5 หลายเดือนก่อน

      the OP made a few syntax errors, here's my entire comments.inc.php file which resolves the problems:

  • @goglesuciha4321
    @goglesuciha4321 7 ปีที่แล้ว

    "i'm new in here"
    this kind of comment is not acceptable in here .. what can i do for that ? i mean for a ( ' ) sign

  • @sudhakarsudha9655
    @sudhakarsudha9655 7 ปีที่แล้ว

    what is the use of -> operator can you explain it simply

    • @daniellajohansson
      @daniellajohansson 7 ปีที่แล้ว

      It is OOP (Object Oriented Programming). The variable $conn is an instance of a class and the -> (arrow) is pointing to a method (function) that is inside the class that $conn is of.
      Hope I got it right.
      Here is the mysqli class:
      php.net/manual/en/class.mysqli.php

  • @marcusriemschneider
    @marcusriemschneider 6 ปีที่แล้ว

    How can I refresh the comments without reloading the website?

    • @Dani_Krossing
      @Dani_Krossing  6 ปีที่แล้ว +2

      You should look into AJAX :)

    • @marcusriemschneider
      @marcusriemschneider 6 ปีที่แล้ว

      mmtuts Oh, Thanks!

    • @marcusriemschneider
      @marcusriemschneider 6 ปีที่แล้ว

      but how can I show the newest comment on top of my website?

    • @jihadbrahim777
      @jihadbrahim777 6 ปีที่แล้ว +1

      the function where you selected from database just change to $sql =" SELECT * FROM posts ORDER BY ID DESC"

  • @tyronnocso5924
    @tyronnocso5924 8 ปีที่แล้ว

    where did $conn came from?

    • @Dani_Krossing
      @Dani_Krossing  8 ปีที่แล้ว

      It comes from the connection we made in the dbh.inc.php file in a previous episode.

    • @tyronnocso5924
      @tyronnocso5924 8 ปีที่แล้ว

      what episode was it? reply please

    • @Dani_Krossing
      @Dani_Krossing  8 ปีที่แล้ว

      The one where we start learning about login systems a few episodes back.

  • @AnimatedAzterkGT
    @AnimatedAzterkGT 5 ปีที่แล้ว +1

    Please helppp mee
    Fatal error: Uncaught Error: Call to undefined function getComments() in C:\xampp\htdocs\wow\second3.php:327 Stack trace: #0 {main} thrown in C:\xampp\htdocs\wow\second3.php on line 327

    • @MAGNETO-i1i
      @MAGNETO-i1i 4 ปีที่แล้ว

      Try turning it off and on again

    • @triggerwarnussy
      @triggerwarnussy 5 หลายเดือนก่อน

      I resolved it, here's my entire comments.inc.php file:

  • @BalaMuruganKamaraj
    @BalaMuruganKamaraj 6 ปีที่แล้ว

    bro how to display the latest comment on top

    • @jihadbrahim777
      @jihadbrahim777 6 ปีที่แล้ว

      $sql =" SELECT * FROM posts ORDER BY ID DESC"

    • @aaronzhang1970
      @aaronzhang1970 6 ปีที่แล้ว

      Jihad Brahim, this doesn't work for me it gives me the error Parse error: syntax error, unexpected '' (T_STRING)

  • @KimKongKun1337
    @KimKongKun1337 7 ปีที่แล้ว

    Source code?

  • @colinmakesvideos
    @colinmakesvideos 8 ปีที่แล้ว +1

    too bad you formatted the $result variable wrong and never explained your error.