Insert custom mysql with viewer_functions

3 posts by 2 authors in: Forums > CMS Builder
Last Post: March 17, 2023   (RSS)

By Dave - March 17, 2023

Hi Alan, 

We have a few internal functions you can use.  Here are some options: 

$colsToValues = [
  'title' => 'test title',
  'content' => 'test content',
];

$newRecordNum = mysql_insert($tableName, $colsToValues);

Or you can get the mySQL object directly with mysqli() like this: 

$result = mysqli()->query($query);
if (!$result) { dieAsCaller("MySQL Error: ". htmlencode(mysqli()->error) . "\n"); }

Hope that helps!  Let me know any questions.

Dave Edis - Senior Developer
interactivetools.com

Thank you Dave

The mysqli object working like a charm y will check mysql_escape() function.

ob_start();
include 'calificaciones_save_post.php';
$output = ob_get_clean();
if (mysqli()->query($output)) {
    header("Location: alumnos.php");
die();
} else {
    dieAsCaller("MySQL Error: ". htmlencode(mysqli()->error) . "\n");
}