?
Solved

PHP Errors Undefined variables,  Object of class stdClass could not be converted to string, form dropdowns

Posted on 2014-02-05
5
Medium Priority
?
1,148 Views
Last Modified: 2014-02-06
I am running WampServer with Apache 2.4., PHP 5.4.3
CodeIgniter 2.1.4
Windows 7 Home Premium

I am trying to use codeigniter for a php application.

I am getting a series of things happening and I don't quite understand whereabouts I should be directing myselef.

I have attached a screen print of the result I am getting

The controller, model and view I am trying to achieve are also attached.

The functionality I am trying to achieve starts with the controller going into the index function and if it is the first time this app has run picker will be 0 then a call to MySQL for distinct listing of years and a distinct listing of leagues this calls the select form and populates the dropdown lists and allows the user to select the year and league they want to work with .

If there is anything else I can relate please ask and I will do my best.

I will be extremely grateful for any help you can give me thank you

John
screenprintphperror.docx
Archery-con.php
Archery-mod.php
Select-Form.php
0
Comment
Question by:johnecollins
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 39835736
I doubt if I can debug your application but I can, perhaps, explain a little about it in a way that might put you on a stronger footing.

The messages you're seeing are not Errors (Error is a term of art in PHP programming).  They are Notices and Warnings.  Usually these lower level messages do not result in script termination.  They may result in data loss and should be corrected.

You'll get a Notice if your script attempts to use an undefined variable.  The Notice will show you the line number.  You would want to go into that script and see what variable was undefined, then trace the logic backwards to the place where the variable should have been defined, and make an assignment statement at that location.  If the undefined variable occurred in an included module, you may find the assignment was "up-stream" in the include path(s).

You'll get a Warning if your script attempts to use the wrong data type.  In the instant case the foreach() statement expects to iterate over an array or an object, but the data passed to foreach() was something else.  This iterator error often happens after a data base query failed, but the failure was undetected.

Here's a little more legible version of the messages.Messages, larger
0
 

Author Comment

by:johnecollins
ID: 39835808
Hi Ray,

Thanks for your advice most helpful and informative. I will continue to analyse and work back from those lines to the point where they should have been initialised.

Thank you very much

John
0
 
LVL 111

Accepted Solution

by:
Ray Paseur earned 2000 total points
ID: 39835870
Hey John:

One of the things about PHP that is particularly pernicious is the default setting for error_reporting().  By default, PHP suppresses Notice messages.  What this means is that scripts can use undefined variables as if they were NULL, FALSE or zero and there is no "heads-up" to give the programmer any hint that something might be wrong.  On the highest level, this could mean that a simple typographical error in a variable name would be devilishly hard to debug.  But at the broad lower level, this means that there are examples of PHP code all over the internet (littering the internet) that were written with the naive assumption that "this is just the way it works."

You may have come across some of those examples.
0
 

Author Comment

by:johnecollins
ID: 39838522
Hi Ray,

I am grateful for your efforts with this question. You helped me face the reluctance I was feeling to sort out my own problems.

When I was writing my question I was wondering if I should have really asked 2 or perhaps 3 different questions, there was the issues I have been having with CodeIgniter, the PHP error reporting  level, variable scope, initialisation.

Unfortunately I was frustrated and annoyed when I wrote my question and I shouldn't have combined it all into 1 question.
Bearing in mind the advice you had given me I determined I would search out the information I needed, I was looking for examples of codeigniter applications so that I could analyse digest and grow from the experience and I found a tutorial about 40 minutes long that answered many of my questions and I am so pleased to pass on the link to this course so that other people can benefit from it.
http://www.revillweb.com/tutorials/codeigniter-tutorial-learn-codeigniter-in-40-minutes/#comment-138.

The course had an excellent bit about private class variables and so I got the whole question cleared up in one hit.

You put me into the correct frame of mind to sort this out so the 500 points are yours
Thank you very much
John
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 39838612
Thanks, John.  Best of luck with your project, ~Ray
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question