Forums

Error msg: Invalid argument supplied for foreach()...

JvdStel 17 Apr, 2010
I am getting the following error (warning) msg from ChronoConnectivity:

Warning: Invalid argument supplied for foreach() in /www/v/v/c/vvckc.nl/public_html/Test1/components/com_chronoconnectivity/libraries/connection.php on line 300



What I am trying to do is read records from a table in mySQL, display on my site and from there on enable updates or deletes.

I assume s'thing is wrong in the Body. See screenshot below:
[attachment=0]Knipsel.JPG[/attachment]

Full code below:

<table style="text-align: left; width: 100%;" border="0" cellpadding="2" cellspacing="0">
  <tbody>
    <tr<?php if ($i % 2) echo ' style="background-color: #EBEBEB;"';?>>
      <td style="width: 5%;">{edit_record} {id}</td>
      <td style="width: 10%;">{datum}</td>
      <td style="width: 10%;">{tijd}</td>
      <td style="width: 10%;">{soort_wedstrijd}</td>
      <td style="width: 10%;">{snummer}</td>
      <td style="width: 10%;">{thuisteam}</td>
      <td style="width: 10%;">{uitteam}</td>
      <td style="width: 10%;">{scheidsrechter}</td>
      <td style="width: 10%;">{thuis_organisatie}</td>
      <td style="width: 5%;">{veld}</td>
      <td style="width: 5%;">{kleedkamer_thuis}</td>
      <td style="width: 5%;">{kleedkamer_uit}</td>
    </tr>
  </tbody>
</table>
<?php $i++ ?>


I'd appreciate some help....




Johan
GreyHead 19 Apr, 2010
Hi JvdStel,

The error is becasue the is no data being loaded from the database for some reason.

Try turning on Site Debug temporarily and look for the MySQL command that is being generated.

Bob
JvdStel 21 Apr, 2010
Bob,

Thanks for the tip. When I turn the site debug on, the site abends the moment I select the menu that launches CC!

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, [email]webmaster@vvckc.nl[/email] and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.



When I approach the table data via the backend however, it does show me all the rows. And the SQL statements do show up in the log:

SELECT count(*) 
  FROM jos_programma
SELECT * 
  FROM jos_programma 
  ORDER BY `id`  
  LIMIT 0,20


And when I select one data element, it nicely opens the predefined form from CF and fills it with data from the selected row. Any idea why it would work in the backend but not in the front end?

Regards,

Johan
GreyHead 22 Apr, 2010
Hi JvdStel,

I suspect that there is something wrong with the menu link. The MSQL is just the standard Joomla lookup to find the component info.

Sometimes the Joomla induced error messages have some more usful info in the top border - do you see anything there?

Bob
JvdStel 23 Apr, 2010
No, nothing. To recap:
[list]
It's no problem to create a report outside CC, using SQL, PHP and HTML
I created a Form with CF that nicely enables new rows to be inserted in the table
CC backend shows all the table rows as expected
CC frontend gives the "Invalid argument supplied for foreach()..." error msg
[/list]

I'm stuck here...
The Header of the "Connection View Settings" displays just fine, but it seems like it never gets to the "body", because no matter what I put in there, it always gets me the error msg.
Is there perhaps a working example of CC V2RC3 I could look at?

Regards,

Johan
GreyHead 24 Apr, 2010
Hi Johan,

I've been through the code here again and don't see anything obviously wrong.

If you want to PM or email me the site URL and a SuperAdmin login I'll take a quick look.

Bob
JvdStel 24 Apr, 2010
I've cracked it!
The original CC module I based on an already existing table, upon which I based my CF form and also the failing CC module discussed in this thread. Last night I turned it around and generated a table based on the CF form. I noticed CF generates 5 columns in addition to the fields I specified originally. My code runs alright now on the new table and the site nicely displays via CC the rows I entered via CF. Aparantly these fields are needed for CC to function properly?

Regards,
Johan
GreyHead 24 Apr, 2010
Hi Johan,

Well done. I think probably the cf_id column made the difference. A primary key column with a different name should work OK, provided that the settings all line up.

Bob
coolgrafix 15 Jun, 2010
Just a note that there are a number of things that could cause this problem. Any SQL syntax problems will trigger this, and honestly the first place to start is (as mentioned above) by turning debugging mode on and looking at the results. In my case, I had specified the ORDER BY field to be "ORDER BY state, city, company". The debugging mode informed me that the SQL being generated contained "ORDER BY ORDER BY state, city, company". So it seems that for that text box, one needs to leave the actual ORDER BY clause out (let CC do the work).

Usability problem here: The tool tip example includes ORDER BY in its wording, suggesting (as with the WHERE clause) that the ORDER BY clause should be entered in the text box as well, along with the actual field names themselves.

Now I know. =)
aryalan 26 Sep, 2011
This is not an error message, simply a notice. It means that the variable referenced does not have a value. This is not usually a problem, if the extension is working normally apart from this then this is nothing to worry about.

The reason that you are seeing it is because the level of error reporting is turned up too high for your site. You can turn it down in your site global configuration. It is a good idea to do this anyway on a live site, because attackers can use deliberately generated messages to find information about your filesystem.

If you see this message and no other output it generally means that you have set the wrong parameters for your extension, and there is no output that corresponds to these parameters. For example, if you are using the featured items module and you have specified a category that does not exist the module will not be able to find any joomla articles to output. You need to check your category ids and other module parameters that select the output.
This topic is locked and no more replies can be posted.