Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I'm trying to rebuild my php/mysql website with mysqli methods. I would to insert a new record in my table SEZIONE, it attributes are:

ID_STAGIONE number (primary key),
ORDINE number,
TITOLO varchar(100),
PUBBLICO varchar(1)

I build dinamically my query, and after i execute it with this istruction:

$db->query($query);

It doesn't work. I decided to print the value of the variable $query, and it is perfect:

insert into SEZIONE (ID_STAGIONE, ORDINE, TITOLO, PUBBLICO) values ('2', '20', 'prova', 'S')

If I execute the query in phpmyadmin sql terminal.. it work! I know that the fields ID_STAGIONE and ORDINE are numbers, so it's not necessary the character ', but it work in phpmyadmin sql terminal. There's anyone that can help me?!?

share|improve this question
    
Is error reporting enabled? –  Idris 2 days ago
    
Yes, I found other errors and I saw them –  user3785826 2 days ago
1  
ID_STAGIONE should be Integer. try to put $db->query($query) or die(mysqli_error($db)); –  Rajlaksh 2 days ago
    
Its should work on phpMyAdmin . That why i give u mysqli_error code to check what the problem with query. Check updated code –  Rajlaksh 2 days ago
    
it return 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 1 –  user3785826 2 days ago
show 8 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.