0
<?php $config['db'] = array ( 'host' => 'localhost' 'username' => 'root' 'password' => '' 'dbname' => 'phplogin' ); $db = new PDO("mysql:host={$config['db']['host']};dbname={$config['db']['dbname']}", $config['db']['username'], $config['db']['password']); ?> 

receives error: "Parse error: syntax error, unexpected ''username'' (T_CONSTANT_ENCAPSED_STRING), expecting ')' in C:\webroot\wamp\www\index.php on line 4"

My question is: Can you highlight or comment on the lines I have to insert my information such as localhost, databasename, table, root, "", etc. Also if you see any changes that need to be made.

2 Answers 2

1

When you get errors, you can find the mistake by looking in the error message The T_CONSTANT_ENCAPSED_STRING parser token error occurs due to an unexpected quote, so all you had to do is look at your code to notice that you don't have commas in the array declaration as stated by Johnny000. You always have to look the error messages and interpret their meaning. That's coding 101 in my opinion.

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

Comments

0

The error is because you forget to seperate the arrayvalues with ,

Here the right code

<?php $config['db'] = array ( 'host' => 'YOURHOST', 'username' => 'YOURUSERNAME', 'password' => 'YOURPASSWORD', 'dbname' => 'YOURTABLE' ); $db = new PDO("mysql:host={$config['db']['host']};dbname={$config['db']['dbname']}", $config['db']['username'], $config['db']['password']); ?> 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.