map200uk Posted May 26, 2007 Share Posted May 26, 2007 hi, im having problems with part of my code-which did previously work function addtoPlaylist() { $play=array(); $play=$_GET['path']; //echo $_GET['path']; $_SESSION['song'][]=$play; } anyone have any ideas how to fix? thanks! Fatal error: [] operator not supported for strings in /opt/lampp/htdocs/beta/phpdb/playlist.php on line 32 Link to comment https://forums.phpfreaks.com/topic/53070-cannot-use-on-string/ Share on other sites More sharing options...
MadTechie Posted May 26, 2007 Share Posted May 26, 2007 ok theirs few things wrong with that! is $_SESSION['song'] an array ? theirs no start_session(); $play=array(); $play=$_GET['path']; should be $play=array(); $play[]=$_GET['path']; Link to comment https://forums.phpfreaks.com/topic/53070-cannot-use-on-string/#findComment-262177 Share on other sites More sharing options...
map200uk Posted May 26, 2007 Author Share Posted May 26, 2007 session_start is at the top of the page, i only included the function, sorry $_SESSION['song'] is an array yep meant to hold all the paths of the songs but well its not working Link to comment https://forums.phpfreaks.com/topic/53070-cannot-use-on-string/#findComment-262180 Share on other sites More sharing options...
MadTechie Posted May 26, 2007 Share Posted May 26, 2007 do a var_dump($_SESSION['song']); Link to comment https://forums.phpfreaks.com/topic/53070-cannot-use-on-string/#findComment-262182 Share on other sites More sharing options...
map200uk Posted May 26, 2007 Author Share Posted May 26, 2007 array(1) { [0]=> string(51) "http://148.197.34.121/mp3/07-maroon_5-cant_stop.ogg" } so it adds it there, but each time it gets overwritten with the next selection, i did have it working right (not quie sure what o changed) so it adds each path as the next element in the song array Link to comment https://forums.phpfreaks.com/topic/53070-cannot-use-on-string/#findComment-262186 Share on other sites More sharing options...
MadTechie Posted May 26, 2007 Share Posted May 26, 2007 try function addtoPlaylist() { array_push($_SESSION['song'],$_GET['path']); } Link to comment https://forums.phpfreaks.com/topic/53070-cannot-use-on-string/#findComment-262188 Share on other sites More sharing options...
map200uk Posted May 26, 2007 Author Share Posted May 26, 2007 still not working-any ideas what could be causingthis? Link to comment https://forums.phpfreaks.com/topic/53070-cannot-use-on-string/#findComment-262189 Share on other sites More sharing options...
map200uk Posted May 26, 2007 Author Share Posted May 26, 2007 now its working again-using function addtoPlaylist() { $play=array(); $play=$_GET['path']; //echo $_GET['path']; $_SESSION['song'][]=$play; } i dont see what the difference is?! Link to comment https://forums.phpfreaks.com/topic/53070-cannot-use-on-string/#findComment-262195 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.