Va benissimo, usa json. Quello che dico io è di fare qualcosa del tipo
Codice PHP:
$row = mysql_fetch_array($result);
$ID = $row["id"];
$LIBRO = ucfirst(strtolower($row["product_name"]));
// Stringa json come questa {"name":"ANTONIO","sex":"male","surname":"ROSSI","age":"29 ANNI","city":"BARI"}
$USERFIELDS = $row["user_fields"];
$USERFIELDS = base64_encode($USERFIELDS);
echo"<body onload=\"createOrder('./include/books/".$LIBRO.".xml', '$USERFIELDS');\">";
Poi nella funzione createOrder devi fare il base64_decode. Se la funzione createOrder è una funzione javascript, basta che usi il metodo che ti ho lincato, se invece è uno script php, prendi il parametro in ingresso e fai qualcosa del tipo
Codice PHP:
$USERFIELDS = base64_decode($USERFIELDS);