Hey there,
I have posted a little piece of code at http://pastebin.org/9683 - it's a prepared query (mysqli).
It works fine as long as I'm inserting some actual values. My problem is that in cases where $name is empty, I want to insert the MySQL null value instead of an actual value.
This can't be done just by $stmt->bind_param('is', $user_id, 'NULL'), as this will insert "null" as a string.
I found one way to solve the problem - by writing $sql = '... VALUES (?, NULL)' instead of $sql = '... VALUES (?, ?)' - But this is a very bad and inflexible solution.
I know that I can just use regular queries, but if possible, I would really like to stick to prepared queries!
Any suggestion to how to solve this problem smoothly?
Best regards
Julius