0

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

2 Answers 2

1

Use the concatenation operator.

Sign up to request clarification or add additional context in comments.

Comments

0

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 ?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.