I have the following class in php:
<?php
class contaEntrada {
public $mostraDados;
public $insereDados;
function conectar(){
$host = "localhost";
$user = "root";
$pass = "root";
$dbname = "fluxo_de_caixa";
try {
$opcoes = array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION);
$pdo = new PDO("mysql:host=localhost;dbname=fluxo_de_caixa;", "root", "root", $opcoes);
} catch (Exception $e) {
echo $e->getMessage();
}
return $pdo;
}
function insereConta($id_empresa, $cat, $subcat, $val, $forPag, $data){
$pdo = conectar();
$val = floatval(str_replace(',', '.', str_replace('.', '', $val)));
if($data == ''){
$data = date("Y-m-d");
}
$this->insereDados->$pdo->prepare("INSERT INTO entrada (id_entrada, id_empresa, categoria, subcategoria, valor, forma_pagamento, data) VALUES (?, ?, ?, ?, ?, ?, ?)");
$this->insereDados->bindValue(1, NULL);
$this->insereDados->bindValue(2, $id_empresa);
$this->insereDados->bindValue(3, $cat);
$this->insereDados->bindValue(4, $subcat);
$this->insereDados->bindValue(5, $val);
$this->insereDados->bindValue(6, $forPag);
$this->insereDados->bindValue(7, $data);
$this->insereDados->execute();
}
<?
Then, I call the class and the function:
<?php
require_once "con/conexao.php";
require_once "classes/contaEntrada.php";
$entrada = new contaEntrada();
$id_empresa = 1;
$cat = 1;
$subcat = 1;
$val = "100,00";
$forPag = "Blablabla";
$data;
$entrada->insereConta($id_empresa, $cat, $subcat, $val, $forPag, $data);
?>
However, when I run the function, the message "SERVER ERROR 500" appears on the screen. Can anyone help me?