Это видео недоступно.
Сожалеем об этом.

Show comment message from the database - PHP tutorial

Поделиться
HTML-код
  • Опубликовано: 22 янв 2016
  • Show comment message from the database - Learn PHP backend programming. Today we will display the comments we uploaded in the previous episode.
    --
    mmtuts is a RUclips channel that focuses on teaching beginner and advanced courses in various multimedia related skills.
    We plan to make tutorials available on programming, video production, animation, graphic design, and on software such as the Adobe Creative Cloud programs.
    PHP for beginners is a how to series that teaches the PHP coding language to people who are just starting out learning programming. The course teaches how PHP scripting can be made easy and teaches how to build many apps such as a login system, a comment section, how to upload images, how to create users in a website, and much more. Creating dynamic websites with PHP is easy and should not be seen as otherwise, which is why we want to explain the language in a easy to understand way for beginners.
    If you have suggestions on new courses, or specific lessons within existing courses you would like to see, then feel welcome to submit them in the comment section or in a private message. ALL suggestions will be seen, but not all will be replied to since we get quite a few every day.

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

  • @turboromy
    @turboromy 7 лет назад

    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.

  • @robertbeauchamp6760
    @robertbeauchamp6760 7 лет назад +4

    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.

  • @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 2 года назад

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

  • @SoccerEFM
    @SoccerEFM 6 лет назад +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

  • @nelsirc9152
    @nelsirc9152 6 лет назад +1

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

  • @cyronadebz8700
    @cyronadebz8700 4 года назад

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

  • @juancarlosdomingo4991
    @juancarlosdomingo4991 5 лет назад +3

    Where's the next tutorial video after this video?

  • @gloriabukachi1
    @gloriabukachi1 5 лет назад +4

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

  • @eliottdonatien1519
    @eliottdonatien1519 6 лет назад

    I am learning a lot with your videos thanks man !

  • @chrisjacobs3360
    @chrisjacobs3360 5 лет назад

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

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

    text just going straight i already add .

  • @dougyhardy356
    @dougyhardy356 3 года назад

    Thankyou Dani for these great tuts

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

  • @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");

  • @carolinezamora2389
    @carolinezamora2389 7 лет назад +7

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

    • @lilvc3469
      @lilvc3469 5 лет назад

      Yup

    • @gloriabukachi1
      @gloriabukachi1 5 лет назад

      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:

  • @vojka2973
    @vojka2973 7 лет назад

    Great teacher

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

    Thank you very much !

  • @nujood3423
    @nujood3423 6 лет назад

    Great job. thank you so much sir

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

  • @MehediHasan-zi2yg
    @MehediHasan-zi2yg 5 лет назад

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

  • @AbhikShrestha
    @AbhikShrestha 6 лет назад +1

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

  • @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 2 месяца назад

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

  • @grizzly9180
    @grizzly9180 5 лет назад

    Great tutorial, great accent

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

  • @diyandy3172
    @diyandy3172 5 лет назад

    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.

  • @diviiniity6529
    @diviiniity6529 7 лет назад +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?

  • @daniellajohansson
    @daniellajohansson 7 лет назад

    Thanks... works great.

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

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

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

  • @johnmartininfante3754
    @johnmartininfante3754 7 лет назад +1

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

  • @mnunez6153
    @mnunez6153 4 года назад

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

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

  • @blackwins7397
    @blackwins7397 3 года назад +1

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

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

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

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

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

  • @sirahmed6562
    @sirahmed6562 6 лет назад

    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

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

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

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

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

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

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

  • @k-lo-kpromo1726
    @k-lo-kpromo1726 4 года назад

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

  • @brzjason
    @brzjason 6 лет назад +1

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

  • @iosmayank
    @iosmayank 8 лет назад

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

  • @xito7271
    @xito7271 7 лет назад

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

  • @mano2012ful
    @mano2012ful 7 лет назад

    awesome man

  • @PikatchuVk
    @PikatchuVk 5 лет назад

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

  • @mackynikat8833
    @mackynikat8833 3 года назад

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

  • @J_yung_
    @J_yung_ 6 лет назад

    which one is the previous episode before this?

  • @AnimatedAzterkGT
    @AnimatedAzterkGT 5 лет назад

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

  • @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 2 месяца назад

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

  • @oliverkirkpatrick1231
    @oliverkirkpatrick1231 7 лет назад

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

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

  • @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 2 месяца назад

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

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

    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 2 года назад

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

  • @primedesigns6046
    @primedesigns6046 7 лет назад

    Love your tutorials so much man, I have a question though. How does RUclips 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 RUclips.
      I'm not sure which method exactly RUclips 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 RUclips 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

  • @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 6 лет назад

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

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

  • @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 5 лет назад

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

  • @kaiqin5224
    @kaiqin5224 6 лет назад

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

  • @ivicahpps
    @ivicahpps 7 лет назад

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

  • @demona625
    @demona625 5 лет назад

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

  • @maxbleib
    @maxbleib 6 лет назад

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

  • @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 лет назад

      ruclips.net/video/Qt9W6U3msOk/видео.html

    • @assamesedictionary2606
      @assamesedictionary2606 6 лет назад

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

  • @christianlabandero2631
    @christianlabandero2631 7 лет назад

    it wont show the comments below..

  • @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 6 лет назад

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

  • @oliverkirkpatrick1231
    @oliverkirkpatrick1231 7 лет назад

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

  • @ltulip9297
    @ltulip9297 7 лет назад

    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  7 лет назад

      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 7 лет назад

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

    • @Dani_Krossing
      @Dani_Krossing  7 лет назад

      I plan to do it in the future :)

    • @ltulip9297
      @ltulip9297 7 лет назад

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

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

  • @k-lo-kpromo1726
    @k-lo-kpromo1726 4 года назад

    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

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

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

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

  • @wesleymacinnis7506
    @wesleymacinnis7506 7 лет назад

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

  • @noureenaraza6159
    @noureenaraza6159 7 лет назад

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

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

  • @plexodus1435
    @plexodus1435 7 лет назад

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

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

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

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

  • @tobiasheide8866
    @tobiasheide8866 7 лет назад

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

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

  • @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 2 месяца назад

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

  • @turboromy
    @turboromy 7 лет назад

    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 7 лет назад

      Strangely, Chrome did update after a while.

    • @wilsongaturu134
      @wilsongaturu134 7 лет назад

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

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

  • @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 2 месяца назад

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

  • @kimgriffith7490
    @kimgriffith7490 7 лет назад

    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 7 лет назад

      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 2 месяца назад

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

  • @marcusriemschneider
    @marcusriemschneider 6 лет назад

    How can I show the newest comment on top of the website?

    • @jihadbrahim777
      @jihadbrahim777 6 лет назад

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

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

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

  • @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 (?)

  • @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 7 лет назад

      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 7 лет назад

      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.

  • @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 7 лет назад

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

  • @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 2 месяца назад

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

  • @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 3 года назад

      Try turning it off and on again

    • @triggerwarnussy
      @triggerwarnussy 2 месяца назад

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

  • @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 7 лет назад

    where did $conn came from?

    • @Dani_Krossing
      @Dani_Krossing  7 лет назад

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

    • @tyronnocso5924
      @tyronnocso5924 7 лет назад

      what episode was it? reply please

    • @Dani_Krossing
      @Dani_Krossing  7 лет назад

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

  • @KimKongKun1337
    @KimKongKun1337 6 лет назад

    Source code?

  • @colinmakesvideos
    @colinmakesvideos 7 лет назад +1

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