I am trying to insert print_r output into database?
In the database, the result is 1?
How to solve this problem?
<?php
processLog(print_r($dataArray));
function processLog($text) {
global $process, $db, $groupID;
print($text . "\n");
$SQL = "INSERT INTO enable_log (process_id, process_date, group_id, log_output, log_time)
VALUES(:process_id, :process_date, :group_id, :log_output, now())";
$q = $db->prepare($SQL);
$q->bindValue(":process_id", $process['pid']);
$q->bindValue(":process_date", $process['date']);
$q->bindValue(":group_id", $groupID);
$q->bindValue(":log_output", $text);
$q->execute();
}
?>
Instead of storing the output of
print_r()(which you can do with @xzyfer ‘s answer), I would suggest usingserialize()so that PHP can reverse the string back into a proper array if you ever need to pull it back out of the database.