Author Topic: Creating Rating script for radiodj (Listener is able to like or dislike songs)  (Read 1626 times)

PresidentOfACPJ

  • Full Member

  • Offline
  • ***
  • 100
  • Personal Text
    We play all kinds of Rock!
    • RADIO ROCK FM - O ROCK ALTERNATIVO COM PITADAS DE CLASSIC ROCK!
Im working in  aproject, where listeners will be able to like or dislike songs.

I will consider this posts to askall my questions bout programming my script,that im confused.

Im studying PHP and other languages, but theres along timethat i hadnt written some not simple PHP codes.

Considering this...


ALL MY QUESTIONS ARE in ANSWERS BELOW:
Rádio Rock FM:

http://radiorockfm.com.br/
twitter.com/radiorockfmreal/
fb.com/radiorockfmreal/

PresidentOfACPJ

  • Full Member

  • Offline
  • ***
  • 100
  • Personal Text
    We play all kinds of Rock!
    • RADIO ROCK FM - O ROCK ALTERNATIVO COM PITADAS DE CLASSIC ROCK!
1.

Code: [Select]

VALUES ( '748', 'Pearl Jam', 'Can't Deny Me', '', '2019.03.11 05:12:37', '2019.03.11 02:11:49', '00:02:41')
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 't Deny Me', '', '2019.03.11 05:12:37', '2019.03.11 02:11:49', '00:02:41')' at line 2

How to solve this problem with songs with ' for example: "Van Halen - I can't Stop Loving you"

You can see theres  ' inside the song, i believe it cn be making problem with inserting data on db.


Like/dislike script is getting ready.

Its just missing to solve that issue when you hve a song with " ' "  :bash:

This simple caractere ( ' )  it is really an error when a song has it in the songs name,like "Canat leave without you" Because of the "" im gonna try to change the CODE OPENING AND SHUTTING (''") FOR THE SIMPLE,THEN CHANGE THE INSIDE SIMPLE for ("""").

came back with results!  :ok:
Rádio Rock FM:

http://radiorockfm.com.br/
twitter.com/radiorockfmreal/
fb.com/radiorockfmreal/

PresidentOfACPJ

  • Full Member

  • Offline
  • ***
  • 100
  • Personal Text
    We play all kinds of Rock!
    • RADIO ROCK FM - O ROCK ALTERNATIVO COM PITADAS DE CLASSIC ROCK!
2. HOW TO get data from the colum 'path' in table songs? with PHP to UPDATE other field?

(Imjust alitle bit confudes, now, bout getting this content and send it to my script){Actualy itll be pratically part of my script hehehe}
Rádio Rock FM:

http://radiorockfm.com.br/
twitter.com/radiorockfmreal/
fb.com/radiorockfmreal/

Jhonny

  • Hero Member

  • Offline
  • *****
  • 3403
  • Personal Text
    Peace, enjoy life.it's over before you've lived it
    • Jhonny's RadioDJ tutorials.
Look on https://www.w3schools.com/
Someting like this
Code: [Select]
<?php
$servername 
"";
$username "";
$password ="";
$dbname ="";
###Connecting using mysqli ###
$conn = new mysqli($servername$username$password$dbname);
### get the path ### long list
$sql="select * from songs";
$result=mysqli_query($conn,$sql);
$row=mysqli_fetch_array($result);
echo 
"$row[path]"<br>";

##for change data wher path is ##
$query =  "UPDATE songs
SET artist
=new_artist_nametitle=new_title_name
WHERE path 
$path";
?>
R.T.F.M. means to me, Read The Fantastic Messages.
Make things simple, but don't make simple things simpler!
I don't do drugs, I do tuts. ( ͡° ͜ʖ ͡°) visit https://radiodj.info

Testing v.2.0.1.5 beta

PresidentOfACPJ

  • Full Member

  • Offline
  • ***
  • 100
  • Personal Text
    We play all kinds of Rock!
    • RADIO ROCK FM - O ROCK ALTERNATIVO COM PITADAS DE CLASSIC ROCK!
Thanks Jhonny!  :cool:

Anyway, I'm excited thinking bout probably in the future version of RadioDJ, Marius could add the table that receive data from the website,maybe someone with plugin knowledge could help. i still don't have any knowledge bout how to produce plugin.   :(
Rádio Rock FM:

http://radiorockfm.com.br/
twitter.com/radiorockfmreal/
fb.com/radiorockfmreal/

PresidentOfACPJ

  • Full Member

  • Offline
  • ***
  • 100
  • Personal Text
    We play all kinds of Rock!
    • RADIO ROCK FM - O ROCK ALTERNATIVO COM PITADAS DE CLASSIC ROCK!
Hey guys! Jhonny?

I got  problem when trying to count likes in database automatically when a new like is inserted.

I ve tried to  UPDATE with +1 butitsnot working right, it always increases+2, idk more wut to try, got tired,gonna restthentry again,I want it to be increased 1/1 not 2/2


THIS IS THE CODE THAT UPDATE THE LIKE COLUM:

Code: [Select]

<?php 
$likes_counter 
"UPDATE rating SET liked = liked + 1 WHERE songID=$songID_got";

if (mysqli_query(@$opened_db$likes_counter)) {
echo json_encode("Thanks !");
} else {
  
    echo "Error: " $likes_counter "<br>" mysqli_error($opened_db);
}
?>


I didntwant,but probably i ll need to use SELECT firteverythingthen count, etc... :bash:

WellL FOR WHILE im gonna let it counting 2/2 .  :hihi:


iMTHINKIN SERIOUSLY IN LET LIKED field in databases table as varchar and send the result of a operation hehehehehe  :hihi:


then i wouldmake the count script to everylike received then sent only the result as varchar,wut do you think of it?
Orits betterto find a way to send it as INT?

Rádio Rock FM:

http://radiorockfm.com.br/
twitter.com/radiorockfmreal/
fb.com/radiorockfmreal/

PresidentOfACPJ

  • Full Member

  • Offline
  • ***
  • 100
  • Personal Text
    We play all kinds of Rock!
    • RADIO ROCK FM - O ROCK ALTERNATIVO COM PITADAS DE CLASSIC ROCK!
RATING SCRIPT IS ALMOST READY FOR USE!

Probably itll be avaliable tobe tested next monday morning, im finishing somedetails.

Pratically i just have to insert some style, and validations!

Thanks for supporting.
Rádio Rock FM:

http://radiorockfm.com.br/
twitter.com/radiorockfmreal/
fb.com/radiorockfmreal/

PresidentOfACPJ

  • Full Member

  • Offline
  • ***
  • 100
  • Personal Text
    We play all kinds of Rock!
    • RADIO ROCK FM - O ROCK ALTERNATIVO COM PITADAS DE CLASSIC ROCK!
Imwith someproblemsto vlidateuserwhoclicked inrating buttom :(

I haveto blocksubmitbutton,afterthat,cananyonetellmeagoodandfastwaytodo it, Javascript isapieceof...

PHPis my honey,but javascriptim stilloutof it,haveto learnmore :( :bash:

anyway,i needto makevalidation is forwassubmitted ifyes,buttonisblocked,orisitposibleyetevenin PHP?
Rádio Rock FM:

http://radiorockfm.com.br/
twitter.com/radiorockfmreal/
fb.com/radiorockfmreal/

Jhonny

  • Hero Member

  • Offline
  • *****
  • 3403
  • Personal Text
    Peace, enjoy life.it's over before you've lived it
    • Jhonny's RadioDJ tutorials.
I recommend using it's own table and not the table of radiodj, with an update of radiodj the table of radiodj can change and chances are that your rating script no longer works


You can make columns with your own ratings table
ID - SONG ID - UP - DOWN - IP - DATE

the IP kolum  can be used for the number of times that a reting can be done on ip address
R.T.F.M. means to me, Read The Fantastic Messages.
Make things simple, but don't make simple things simpler!
I don't do drugs, I do tuts. ( ͡° ͜ʖ ͡°) visit https://radiodj.info

Testing v.2.0.1.5 beta

stevewa

  • Sr. Member

  • Offline
  • ****
  • 382
to prevent the same user from liking the same song too many times, set a cookie in the browser, and then check that cookie., if it has a value like "already_rated: 1" and the amount of time that has elapsed since the cookie was set, is less than the typical song length (i.e. the same song that they just rated is still playing so they can't rate it again, but if a new song has started and they want to rate it, then ignore the cookie restriction),  then disable the button in the dom using javascript. BUT, if bots get a hold of your app, then this method will be overwritten, lol, then you'd need to check it server side with the php. even better would be to use javascript and create a js function to enable and disable the submit button to make it harder for bots to get around it and spam your server. also, make sure you add some validation to your php script, so crackers can't do sql injection thru your php script and destroy your entire database and gain admin access to your computer...

Jhonny

  • Hero Member

  • Offline
  • *****
  • 3403
  • Personal Text
    Peace, enjoy life.it's over before you've lived it
    • Jhonny's RadioDJ tutorials.
Then you have to ask if cooky can be used
R.T.F.M. means to me, Read The Fantastic Messages.
Make things simple, but don't make simple things simpler!
I don't do drugs, I do tuts. ( ͡° ͜ʖ ͡°) visit https://radiodj.info

Testing v.2.0.1.5 beta

PresidentOfACPJ

  • Full Member

  • Offline
  • ***
  • 100
  • Personal Text
    We play all kinds of Rock!
    • RADIO ROCK FM - O ROCK ALTERNATIVO COM PITADAS DE CLASSIC ROCK!
Quote
You can make columns with your own ratings table
ID - SONG ID - UP - DOWN - IP - DATE


Ive done pratically this, but with no IP,inserting IP here, i wouldnt be ble to allow tha ip to like thesamesong ,when its playing aftersomehours for example, would i?
Rádio Rock FM:

http://radiorockfm.com.br/
twitter.com/radiorockfmreal/
fb.com/radiorockfmreal/

PresidentOfACPJ

  • Full Member

  • Offline
  • ***
  • 100
  • Personal Text
    We play all kinds of Rock!
    • RADIO ROCK FM - O ROCK ALTERNATIVO COM PITADAS DE CLASSIC ROCK!
Quote
Then you have to ask if cooky can be used


I realy didnt understand what you metnhere :)
Rádio Rock FM:

http://radiorockfm.com.br/
twitter.com/radiorockfmreal/
fb.com/radiorockfmreal/

PresidentOfACPJ

  • Full Member

  • Offline
  • ***
  • 100
  • Personal Text
    We play all kinds of Rock!
    • RADIO ROCK FM - O ROCK ALTERNATIVO COM PITADAS DE CLASSIC ROCK!
what is the most security way to getuser ipto mke tht validation, i got a script in javscript to disable the buton like/dislike, but i cnt configure it for the same song duration, omg, maybe you guys can help me, im gonna insert it here...

IT WORKS, but i decide one periodof time, but ive tried to insert the avascrit's song duration variable, but with no sucess :(

its hard :bash:

NOW I've JUST noticed that my script javascript is god if igetsome validation berfore forsure, i've been ignoring the fact of that i canot disble the button for 2 minutes (for example) becuase itll be disable to everyone, not only the last ipwho liked that song, so the songs will only get praically always 1 like  :D :D :D :D :D

Rádio Rock FM:

http://radiorockfm.com.br/
twitter.com/radiorockfmreal/
fb.com/radiorockfmreal/

Jhonny

  • Hero Member

  • Offline
  • *****
  • 3403
  • Personal Text
    Peace, enjoy life.it's over before you've lived it
    • Jhonny's RadioDJ tutorials.
Show the script mebe we can help or read problems.  8) If the script is to big you can upload it to me abd i can set a download link on the forum.
upload link to me

 
R.T.F.M. means to me, Read The Fantastic Messages.
Make things simple, but don't make simple things simpler!
I don't do drugs, I do tuts. ( ͡° ͜ʖ ͡°) visit https://radiodj.info

Testing v.2.0.1.5 beta