By rix.kostenko on
Hi,
Not sure if this is the best place to post this but i'm having problems trying to insert the following into my db using mysqli. I keep getting unexpected '-' or unexpected T_VARIABLE errors.
Any idea how i can solve this please?
$query = "INSERT INTO the_transactions VALUES (
'$my_var',
'$page_one[input-one]',
'$page_one[check-one]',
'$page_one[title]',
)";
Comments
You should really use the
You should really use the database API for this to prevent injection attacks, something like this:
'unexpected T_VARIABLE' errors are usually because you're code's missing a curly brace or there's a space between <? and php at the beginning of the file, something like that.
Didn't even realise there was
Didn't even realise there was a database api - thanks!
Not good style
use 'drupal_write_record' instead
http://api.drupal.org/api/drupal/includes--common.inc/function/drupal_wr...