[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
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");
}
}
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]);
}
}
enum Playlist
{
PlaylistID,
SongName[30],
SongStream[255],
SongsInserted
}
new PlaylistInfo[MAX_PLAYERS][Playlist];
Creating the foreign key
You should've been brought back to the structures tab. Navigate there if this isn't the case. Underneath the structure definition you should see a link titled Relation view. Click this to be brought to the "relation creator". I'm creating a link to the id field in the table playerinfo in the database vcnr. Your table and database will be called differently. Select the proper ID. Note that for fields to show up in this list, they need to be defined as a key! We also want any changes made in the main table to be CASCADED into this table. Click Save. This concludes the table creation part in phpMyAdmin. Now back to Pawn. |
If you don't get it, try rename PlayerPlayListID in each table to a different name
|
mysql_format(mysql, query, sizeof(query), "INSERT INTO `songs` (`SongStream`, `SongName`, `PlayerPlaylistID`) VALUES('%e', '%e', '%d')", PlaylistInfo[playerid][SongStream], inputtext, PlaylistInfo[playerid][PlaylistID]);
SELECT COUNT(*) FROM `songs` WHERE PlaylistID=%i |