Jump to content

Warning: Invalid argument supplied for foreach() in Schedules_results


FlyingMachine

Recommended Posts

Well, I don't see what the issue is.

foreach(), as the name says, does the same action for each of the objects in the array. If the search is without results, it won't have anything to go over and will give you an error saying that what you have supplied as an argument to the function is invalid (empty in this case).

What you can do is something like this.

<?php
if($flights_variable) {
foreach($flights_variabls as $flight) {
//do stuff
}
} else {
echo 'There are no flights for your search criteria';
}

You get the overall idea I hope.

And also, as there have been a lot of posts lately similar to yours, Google is your friend, and errors in PHP are usually pretty straight forward. It would have taken you less time to find and answer using Google then it would have taken for me or someone else to reply. And, you would have learned something new along the way. Just a friendly tip.

Sava

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...