Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6171931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:18:19+00:00 2026-05-23T23:18:19+00:00

I am a beginner level php programmer. I was trying to use the MVC

  • 0

I am a beginner level php programmer. I was trying to use the MVC but I can’t even get past the testing of this one.

Problem: Warning: Invalid argument supplied for foreach() in httpdocs/data/serieDAO.php on line 15

Can anyone give me a tip to what is causing this problem?

The code (sorry if it is very long):

/index.php

<?php 
ini_set('display_errors', 1);
// main controller
require_once ("business/serieservice.php");
$service = new SerieService();
$serielijst = $service->toonAlleSeries();
include("test/test1.php");
?>

/business/serieservice.php

<?php
require_once("data/serieDAO.php");
class SerieService{

    public function toonAlleSeries(){
        $serieDAO = new SerieDAO();
        $lijst = $serieDAO->displayList();
        return $lijst;
    }
}
?>

/data/serieDAO.php

 <?php
require_once("entities/series.class.php");

class SerieDAO{

    // public function __construct(){
        // $dbh = new PDO("mysql:host=localhost;dbname=tvseasons", "seasons", "bompa");
    // }

    public function displayList(){
        $list = array();
        $dbh = new PDO("mysql:host=localhost;dbname=tvseasons", "seasons", "bompa");
        $sql = "select id, title, desc, url, genre, trailer from Series";
        $resultSet = $dbh->query($sql);
        foreach ($resultSet as $row){
            $serie = new Series($row["id"], $row["title"],$row["desc"], $row["url"], $row["genre"], $row["trailer"]);
            array_push($list, $serie);
        }
        $dbh = null;        
        return $list;
    }


}
?>

/entities/series.class.php

<?
//class met getters en setters van series entity
class Series{
  private $id;
  private $title;
  private $desc; //description
  private $url;
  private $genre;
  private $trailer;

  /* Try to figure out how to determine the $id. Cannot be set obviosly but get should be possible */

  //setters
  function setTitle ($title){
    $this->title = $title;
  }
  function setDesc($desc){
    $this->desc = $desc;
  }
  function setUrl($url){
    $this->url = $url;
  }
  function setGenre($genre){
    $this->genre = $genre;
  }
  function setTrailer($trailer){
    $this->trailer = $trailer;
  }

  //getters
  function getTitle(){
    return $this->title;
  }
  function getDesc(){
    return $this->desc;
  }
    function getUrl(){
    return $this->url;
  }
    function getGenre(){
    return $this->genre;
  }
    function getTrailer(){
    return $this->trailer;
  }
}
?>

/test/test1.php

<html>
<head>
<title>Test1 lijst series</title>
</head>
<body>
<h1>Een lijst van alle series</h1>
<ul>
<?php
foreach($serielijst as $serie){
 print ("<li>bla bla</li>");
}
?>
</ul>
</body>
</html>

edit: I know the code Inside the foreach is not working yet. But I already figured out that that is not the cause.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T23:18:19+00:00Added an answer on May 23, 2026 at 11:18 pm

    Your query is failing to return an array with the result-set, because you are using a reserved word (desc) for one of the table columns.

    Change:

    $sql = "select id, title, desc, url, genre, trailer from Series";
    

    to:

    $sql = "select id, title, `desc`, url, genre, trailer from Series";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a beginner level question for asp.net MVC I have the following code
I'm a beginner level programmer trying to make a game app for the iphone
Excuse the beginner level of this question. I have the following simple code, but
This is a beginner level task. I am trying to implement a calendar widget
I have worked on Mozilla Add-on Development in the past (beginner level). But on
I'm looking for suggestions for a beginner level ASP/XML test. Essentially I'm trying to
What database should a beginner use in the C language? Can I use MySQL?
This is a beginner-level question. I have a catalog of mtypes: mtype_id name 1
I have a beginner level Json question with MVC.net (I've never really used jquery
Where can I find tutorials and other beginner-level learning material for developing Windows Mobile

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.