0
I have that function:
$id = pega_assunto_por_nome_menu($_GET['assunto'])['id'];
That returns the id value if you use echo $id;
But when I update to mysql, it doesn’t work.
This error appears:
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 '' at line 3
Line six is the definition of id = {$id};
$atualiza = "UPDATE assuntos SET
nome_menu = '{$nome_menu}'
WHERE id = {$id}";
If I use var_dump, this is the result.
$assunto = pega_assunto_por_nome_menu($_GET['assunto']);
var_dump($assunto);
array (size=10)
0 => string '1' (length=1)
'id' => string '1' (length=1)
1 => string 'Sobre a Preliminartes' (length=21)
'nome_menu' => string 'Sobre a Preliminartes' (length=21)
2 => string 'sobre_a_preliminarte' (length=20)
'nome_menu_slug' => string 'sobre_a_preliminarte' (length=20)
3 => string '1' (length=1)
'posicao' => string '1' (length=1)
4 => string '1' (length=1)
'visivel' => string '1' (length=1)
would not be
$id = pega_assunto_por_nome_menu($_GET['assunto']['id'])
; ?– rray
This error appears if change, Illegal string offset 'id'
– Alê Moraes
Debug this array before moving to the function.
var_dump($_GET['assunto']);
– Diego Moreira
do so :
$assunto = pega_assunto_por_nome_menu($_GET['assunto']);
and thenvar_dump($assunto);
and put the result here...– KaduAmaral
I put the result at the end of the question
– Alê Moraes
@Alêmoraes, I added an answer there, do the test. If it doesn’t work leave in the comments of the reply.
– KaduAmaral
I have not yet managed, I put the whole code of this study in this link: http://pastebin.com/zjwAmbDx
– Alê Moraes
@Alêmoraes managed to?
– KaduAmaral
I got it, I still don’t understand why, kkk, but in the form action, it applied the id instead of the name_menu_slug, hence the function returned zero always
– Alê Moraes