BuzFortuna's code is not needed since you've already got the stockID passed through the URL.
When you pass a variable through the URL, you can retrieve it using the $_GET[] superglobal.
Try replacing:
echo $stockId ;
with:
echo $_GET['stockId'];
Also, I'm assuming you have some IF statement later, that checks the value of 'action=' and calls the view_record() function, right?
Also, at the end of your code snippet, the '?' should have been '?>'. This may just be a typo, I'm not sure.
Also, you are not staying consistent in your PHP tags. Some servers do not use '<?' as a PHP opening tag. To make your script fully compatible, always use '<?PHP' to open a block of PHP code, especially if you can actually see the code on the HTML page.