darkfreaks Posted May 23, 2008 Share Posted May 23, 2008 ok so i get Warning: Cannot use a scalar value as an array in /home/willowg/public_html/global.inc.php on line 74 Warning: Cannot use a scalar value as an array in /home/willowg/public_html/header.inc.php on line 114 those lines are: <?php function makepassword($string ="") { $letters = array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"); if ($string) { $num = rand(10,99); $string .= $num; $x = 0; while ($x < 2) { $which_letter = rand(0,25); $string .= $letters[$which_letter]; $x++; } } if (!$string) { $x = 0; while ($x < 6) { $which_letter = rand(0,25); $string .= $letters[$which_letter]; $x++; } $num = rand(1000,9999); $string .= $num; } return $string;//line 74 function admin_smilies($string) //line 114 { include "config.inc.php"; $smilies = file("$websiteURL/lists/smilies.txt"); $num_smilies = count($smilies); $x = 0; while ($x < $num_smilies) { $array = explode(" ",$smilies[$x]); $array[3] = ereg_replace("\r","",$array[3]); $array[3] = ereg_replace("\n","",$array[3]); $string = eregi_replace($array[0],"<img src=../images/smilies/$array[1] height=$array[2] width=$array[3]>",$string); $x++; } return $string; } ?> anyone got any ideas how i would fix this ??? Quote Link to comment https://forums.phpfreaks.com/topic/106854-solved-php-errors/ Share on other sites More sharing options...
.josh Posted May 23, 2008 Share Posted May 23, 2008 I think the problem has to do with you declaring a variable as one type (by virtue of assigning something to it, of course), and then trying to use it as a different type. I think. Quote Link to comment https://forums.phpfreaks.com/topic/106854-solved-php-errors/#findComment-547759 Share on other sites More sharing options...
darkfreaks Posted May 23, 2008 Author Share Posted May 23, 2008 so how would you go about fixing it ??? i think it is because i use $string in 2 functions and it just uses string over again or something. Quote Link to comment https://forums.phpfreaks.com/topic/106854-solved-php-errors/#findComment-547780 Share on other sites More sharing options...
.josh Posted May 23, 2008 Share Posted May 23, 2008 umm, well I can't really be more specific than that without pouring over your entire code (which I'm not about to do sorry lol) I mean, I'm not necessarily seeing a problem with the code that you provided, so you're probably gonna have to backtrack and see what argument you're trying to pass to your functions. You just have to go through your code and make sure you didn't do anything like declare your variable somewhere else that's under the same jurisdiction as in this function (like a global variable) etc... p.s.- using $string in more than one function doesn't necessarily mean anything. They are both local variables that are trashed when the function breaks...but it might mean something if you have, as mentioned, a global version of it somewhere. Quote Link to comment https://forums.phpfreaks.com/topic/106854-solved-php-errors/#findComment-547792 Share on other sites More sharing options...
.josh Posted May 23, 2008 Share Posted May 23, 2008 I made a separate post because I know you're reading: How about trying a little } after that return, and before your next function. That might possibly be it, because without that, it's like, trying to use your variable in two different ways. Quote Link to comment https://forums.phpfreaks.com/topic/106854-solved-php-errors/#findComment-547795 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.