Jump to content

Need help with PHP Warnings


kts

Recommended Posts

Hey, im using a function to reset and grab each array. When its looping through its fine, but I'm getting this warning I never seemed to have gotten except on Godaddy hosting.

 

Warning: reset() [function.reset]: Passed variable is not an array or object

 

When I set the variable in the URL it removes the error, but without it set i get the warning. I tried setting $_GET['var'] = 0; just to make the warning disappear, but it did not work. Anyone have any suggestions?

Link to comment
https://forums.phpfreaks.com/topic/105586-need-help-with-php-warnings/
Share on other sites

before you pass your variable, make sure the value is an array... That is what is wrong your probably passing a string, number, boolean or some other value,

 

try this:

<?php
if(is_array($someValue)){
     echo 'This is a valid variable.';
     reset($someValue);
}else{
     echo 'This variable will fail the rest function.';
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.