gatez Posted November 29, 2007 Share Posted November 29, 2007 I am very new o php i am getting ths error Fatal error: Cannot use string offset as an array in /theadresses/ line 15 if ( $arFriends != "" ) $arFriends .= ","; $arFriends .= $rs[$i]["uid"]; <--------------------this is line 15 please tell me whats wrong in using php 5 Quote Link to comment https://forums.phpfreaks.com/topic/79464-solved-fatal-error-cannot-use-string-offset-as-an-array-in-please-help/ Share on other sites More sharing options...
sKunKbad Posted November 29, 2007 Share Posted November 29, 2007 If you already have a variable which is a string, you can't append an array to it using .= If you want to replace the variable value with an array, simply use = not .= Quote Link to comment https://forums.phpfreaks.com/topic/79464-solved-fatal-error-cannot-use-string-offset-as-an-array-in-please-help/#findComment-402361 Share on other sites More sharing options...
gatez Posted November 29, 2007 Author Share Posted November 29, 2007 $arFriends = $rs[$i]["uid"]; like that ? Quote Link to comment https://forums.phpfreaks.com/topic/79464-solved-fatal-error-cannot-use-string-offset-as-an-array-in-please-help/#findComment-402363 Share on other sites More sharing options...
gatez Posted November 29, 2007 Author Share Posted November 29, 2007 like i said i am really new at this can someone give me an example i removed the two . and still got the error Quote Link to comment https://forums.phpfreaks.com/topic/79464-solved-fatal-error-cannot-use-string-offset-as-an-array-in-please-help/#findComment-402386 Share on other sites More sharing options...
The Little Guy Posted November 29, 2007 Share Posted November 29, 2007 are you trying to add values to an array? Quote Link to comment https://forums.phpfreaks.com/topic/79464-solved-fatal-error-cannot-use-string-offset-as-an-array-in-please-help/#findComment-402392 Share on other sites More sharing options...
gatez Posted November 29, 2007 Author Share Posted November 29, 2007 i got the sript from a friend im not shure like i said im a noob at php Quote Link to comment https://forums.phpfreaks.com/topic/79464-solved-fatal-error-cannot-use-string-offset-as-an-array-in-please-help/#findComment-402394 Share on other sites More sharing options...
The Little Guy Posted November 29, 2007 Share Posted November 29, 2007 Well then, it is hard to tell what your doing without more code. Quote Link to comment https://forums.phpfreaks.com/topic/79464-solved-fatal-error-cannot-use-string-offset-as-an-array-in-please-help/#findComment-402396 Share on other sites More sharing options...
sKunKbad Posted November 29, 2007 Share Posted November 29, 2007 $arFriends = $rs[$i]["uid"]; like that ? if what you want to do is replace the value of $arFriends, which is a string, with an array which has only one key->value, then this is what you want to do. You should check out some php tutorial websites or read some books. w3schools.com is a good site to learn the basics. Quote Link to comment https://forums.phpfreaks.com/topic/79464-solved-fatal-error-cannot-use-string-offset-as-an-array-in-please-help/#findComment-402484 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.