0
I need to generate a schedule for a certain period, but it’s making this mistake.
Fatal error: Uncaught Exception 'Pdoexception' with message 'SQLSTATE[42000]: Syntax error or access Violation: 1064 You have an error in your SQL syntax; check the manual that Corresponds to your Mysql server version for the right syntax to use near '(day),data_agenda(Month),data_agenda(year)) VALUES('19:00:00','31','12','2016')' at line 1
$dataInicio = '2016-01-01';
$intervalo = 60;
do {
list( $ano, $mes, $dia ) = explode('-', $dataInicio);
$inicio = '07:00:00';
$final = '19:00:00';
do {
list($hora, $minuto, $segundo ) = explode(':', $inicio);
$sql = "INSERT INTO agenda (hora_agenda,data_agenda(day),data_agenda(month),data_agenda(year)) VALUES('$inicio','$dia','$mes','$ano')";
$inicio = date("H:i:s", mktime($hora, $minuto + $intervalo, $segundo, $mes, $dia, $ano));
} while ($inicio <= $final);
$dataInicio = date('Y-m-d', mktime(0, 0, 0, $mes, $dia + 1, $ano));
} while (date('Y') == date('Y', strtotime($dataInicio)));
$dados = connection::exec($sql);
I don’t understand PHP, but putting the name of the variables in quotes will not end up sending the literal to the bank? Ex.:
'$inicio'
will send the literal$inicio
instead of the variable value.– Jéf Bueno
There are some things out of place,
day()
,month()
andyear()
are functions to extract pieces of a date, which is the reason to save 3 times some value in the same column(data_agenda
) ?– rray
You need to explain what you want to do, to make the syntax work just remove
day, month, year
.– rray