Gosh, that's alot of code.
I think the code at line 34 should read:
while(true){
$rnd_string = RandomString();
$sql = mysql_query("SELECT * FROM Reservas WHERE codigo= '{$rnd_string}' ");
$result = mysql_query($sql);
if(mysql_num_rows($result) == 0) break;
}
on line 217 you have a stray semi colon ;
then at lines 316, 324, 335 and 347
you are building up the string for $message and then you need to add a variable. Essentially your code is doing this:
$message = "blah blah" .
$var = $var1 . $var 2;
$var .
" more text to add";
this is invalid as you are still concatenating when you start working on a new variable. You need to change it to
$message = "blah blah";
$var = $var1 . $var 2;
$message .= $var .
" more text to add";
does that make sense?
You need to do some debugging by echoing out $message as you go and see when it gets populated.