First, please make use of the code formatting features of this site so the code that you paste is readable rather than just a jumble of code.
Second, you are obviously having a problem with your PHP syntax. You might want to start by reading about strings in order to understand how they can be specified. You also need to keep in mind that all of your PHP code must lie between the opening <?php tag and the closing ?> tag. For some reason, you end your script with $x=?>
Syntax is an extremely basic thing you must know. If you're having trouble with that, everything else is going to be impossible.