foreach causing error in viewer_functions.php at 1030

2 posts by 2 authors in: Forums > CMS Builder
Last Post: July 27, 2015   (RSS)

By Daryl - July 27, 2015

Hi markr,

Do the page call the getRecords() function?

I checked the viewer_functions.php line 1030 and it's inside the function that is called by getRecords function for constructing the mysql query.
So I'm suspecting that the error is caused by your getRecords() parameters. 
You can set the "debugSql" to true in your getRecords function to help with troubleshooting. "debugSql" will display the mysql queries that the getRecords are executing.

Example:

  list($records, $details) = getRecords(array(
    'tableName'           => 'listings',
    'where'               => '',
    'debugSql'            => true,      // optional, display SQL query, defaults to no
  ));

Also, in your mysql query code above (and everywhere else wherein you're building a query with variables), you should always escape the variable values in your mysql query statement using mysql_escape() function to prevent mysql injections.

Example:

foreach (@$_POST['roomSelect'] as $key => $value) {

$update = mysql_query("
UPDATE $studentTable
SET `room` = '".mysql_escape($value)."'
WHERE `recid` = '".mysql_escape($key)."'
LIMIT 1
") or die(mysql_error());


} // end foreach

Hope that helps!

Cheers,

Daryl Maximo
PHP Programmer - interactivetools.com