I have tried endless variations of mysqli_real_escape_string() to insert a simple array in a column ni one of my tables. The contents of the column is blank everytime.
Can anyone see anything wrong with this query?
$accessRights = array(
'S-01' => 'Y',
'S-02' => 'Y',
);
$accessRights = serialize( $accessRights );
mysqli_query( $GLOBALS['db_link'], 'SET NAMES "utf8"' ); // to ensure proper encoding of special characters
$query_string = '
UPDATE users_accessRights
SET
accessRights = "' . mysqli_real_escape_string( $accessRights ) . '"
WHERE userID = "' . $_POST['userID'] . '"
LIMIT 1
';
mysqli_query( $GLOBALS['db_link'], $query_string ) or die( mysqli_error( $GLOBALS['db_link'] ) );
Note: I can use this query to insert a simple text string into the table, so I know the query itself works.
mysqli_set_charset()instead of theSET NAMESquery