22.09.2016, 22:27
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.
What could be the mistake?
In script code:
ERROR:2 Prints blank song name.
My enum:
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
In script code:
PHP код:
case DIALOG_CUSTOMPLAYLISTSONGNAME:
{
if( response )
{
new query[350];
if(isnull(inputtext)) return ShowPlayerDialog(playerid, DIALOG_CUSTOMPLAYLISTSONGNAME, DIALOG_STYLE_INPUT, ""COL_RED"Invalid Song Name","Please insert a valid song name.","Select", "");
mysql_format(mysql, query, sizeof(query), "INSERT INTO `songs` (`SongStream`, `SongName`) VALUES('%s', '%s')", PlaylistInfo[playerid][SongStream], inputtext);
mysql_tquery(mysql, query);
ShowPlayerDialog(playerid, DIALOG_CUSTOMPLAYLISTSONGPLAY, DIALOG_STYLE_MSGBOX, ""COL_GREEN"You have added the song","Do you want to play song now?","Yes", "No");
}
}
PHP код:
case DIALOG_CUSTOMPLAYLISTSONGPLAY:
{
if( response )
{
new string[60];
format(string,sizeof(string), "CURRENTLY PLAYING: %s", PlaylistInfo[playerid][SongName]);
SendClientMessage(playerid, -1, string);
PlayAudioStreamForPlayer(playerid, PlaylistInfo[playerid][SongStream]);
}
}
PHP код:
enum Playlist
{
PlaylistID,
SongName[30],
SongStream[255],
SongsInserted
}
new PlaylistInfo[MAX_PLAYERS][Playlist];