在MYSQL Connect中使用多个定义的变量

I wish to allow a user to login to their MySQL database. Their username and end of the SQL database is the same, however each Database name starts with; linkycra_[username]

I'm attempting to use defined variables in connecting to the SQL.

It would work with a comma in an echo - however obviously, commas cannot be used in this format.

http://puu.sh/1IBJP.png

Well, there is a lot of thing to fix in your code.

First, don't use an image to paste code, but directly in stackoverflow or if it's too long, in a pastebin-like website.

Then, you should not use mysql_* methods since they are deprecated (read the doc), but PDO instead.

Next, you should never use the value in the cookie directly like this. You must verify it, sanitize and filter it, to be sure the value returned is correct : I can modify this value and with some work, maybe hack your website. Not a good way.

Then, if it's lynkycra_[username], you can use the concatenation of strings (based on your code) :

$link = mysql_connect('server', 'linkycra_'.$_COOKIE['monlotronloggedin'], 'password');

See ?