Playlist System[MySQL]
#1

Hello guys i have 3 tables

players - songs - playlists

-To players table i have added a row named PlayerPlaylistID(UNSIGNED UNIQUE)
-To songs table i have 4 rows. SongID[, SongStream,SongName,PlayerPlaylistID(UNSIGNED UNIQUE)
-To playlists table i have 3 rows. PlaylistID(UNSIGNED AUTO_INCREMENT PRIMARY), PlayerPlaylistID(UNSIGNED UNIQUE), SongsInserted(I want to make up to 10 songs as a limit in each playlist)

I have created some commands and when i insert the song the stream works correctly. However when i print Song name it prints blank and mysql triggers error.

I have made connection between these 3 PlayerPlaylistIDS.

ERROR 1: Triggers Mysql error.
Код:
[01:15:35] [DEBUG] mysql_format - connection: 1, len: 350, format: "INSERT INTO `songs` (`SongStream`, `SongName`) VALUES('%s', '%s')"
[01:15:35] [DEBUG] mysql_tquery - connection: 1, query: "INSERT INTO `songs` (`SongStream`, `SongName`) VALUES('http://ww", callback: "(null)", format: "(null)"
[01:15:35] [DEBUG] CMySQLQuery::Execute[] - starting query execution
[01:15:35] [ERROR] CMySQLQuery::Execute[] - (error #1452) Cannot add or update a child row: a foreign key constraint fails (`server`.`songs`, CONSTRAINT `songs_ibfk_1` FOREIGN KEY (`PlayerPlaylistID`) REFERENCES `playlists` (`PlayerPlaylistID`) ON DELETE CASCADE ON UPDATE CASCADE)
[01:15:35] [DEBUG] mysql_format - connection: 1, len: 720, format: "UPDATE `players` SET `Admin`=%d, `VIP`=%d, `Money`=%d, `Health` =%f, `Armour` =%f, `posX`=%f, `posY`=%f, `posZ`=%f,`Score` =%d, ..."
[01:15:35] [DEBUG] CMySQLQuery::Execute[] - error will be triggered in OnQueryError
What could be the mistake?

In script code:
PHP код:
                case DIALOG_CUSTOMPLAYLISTSONGNAME:
                        {
                            if( 
response )
                            {
                                new 
query[350];
                                if(
isnull(inputtext)) return ShowPlayerDialog(playeridDIALOG_CUSTOMPLAYLISTSONGNAMEDIALOG_STYLE_INPUT""COL_RED"Invalid Song Name","Please insert a valid song name.","Select""");
                                
mysql_format(mysqlquerysizeof(query), "INSERT INTO `songs` (`SongStream`, `SongName`) VALUES('%s', '%s')"PlaylistInfo[playerid][SongStream], inputtext);
                                
mysql_tquery(mysqlquery);
                                
ShowPlayerDialog(playeridDIALOG_CUSTOMPLAYLISTSONGPLAYDIALOG_STYLE_MSGBOX""COL_GREEN"You have added the song","Do you want to play song now?","Yes""No");
                            }
                        } 
ERROR:2 Prints blank song name.
PHP код:
                        case DIALOG_CUSTOMPLAYLISTSONGPLAY:
                        {
                            if( 
response )
                            {
                                
                                new 
string[60];
                                
format(string,sizeof(string), "CURRENTLY PLAYING: %s"PlaylistInfo[playerid][SongName]);
                                
SendClientMessage(playerid, -1string);
                                
PlayAudioStreamForPlayer(playeridPlaylistInfo[playerid][SongStream]);
                                
                            }
                        } 
My enum:
PHP код:
enum Playlist
{
    
PlaylistID,
    
SongName[30],
    
SongStream[255],
    
SongsInserted
}
new 
PlaylistInfo[MAX_PLAYERS][Playlist]; 
Reply


Messages In This Thread
Playlist System[MySQL] - by vassilis - 22.09.2016, 22:27
Re: Playlist System[MySQL] - by Shinja - 22.09.2016, 22:51
Re: Playlist System[MySQL] - by vassilis - 22.09.2016, 23:00
Re: Playlist System[MySQL] - by X337 - 23.09.2016, 03:39
Re: Playlist System[MySQL] - by PrO.GameR - 23.09.2016, 12:24

Forum Jump:


Users browsing this thread: 1 Guest(s)