# Syntax error, unexpected ')'

**URL:** <https://www.ruby-forum.com/t/syntax-error-unexpected/143639>\
**Category:** Rails\
**Created:** [July 21, 2008, 1:24pm UTC](https://www.ruby-forum.com/t/syntax-error-unexpected/143639 "2008-07-21T13:24:25Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ponravikumar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/9de0a6/32.png) [@ponravikumar](https://www.ruby-forum.com/u/ponravikumar)\
**Post date:** [July 21, 2008, 1:24pm UTC](https://www.ruby-forum.com/t/syntax-error-unexpected/143639/1 "2008-07-21T13:24:25Z")

</div>

Hi,

I tried the sample program for AJAX from the following site.

> **[Ajax on Rails](https://www.theregister.com/2007/01/15/ajax_rails_tutorial/)**
>
> Bringing together Ajax and Rails with Prototype

I created a table called catalogs and set the values.

I tried to load the data while entering the title of the book in the  
text field,  
I am getting the error messages

# ===== SyntaxError in CatalogController#get\_article\_list D:/ruby/Projects/catalog/app/models/catalog.rb:14: syntax error, unexpected ‘)’

I tried to identify the cause of the error.  
I colundn’t

# This is the controller

class CatalogController \< ApplicationController

def index  
end

def get\_article\_list  
@section=request.raw\_post

@catalogList=“

”

Catalog.find\_by\_sql( “SELECT \* from catalogs WHERE title =  
'”+@section+“'” ).each do|catalog|  
@catalogList+=“

1. \<a href="”+catalog.url+“"\>” +catalog.title+  
“
”

end

@catalogList+=“

”

render :text =\> @catalogList

```
end

```

# end

# This is model

require ‘rubygems’  
require ‘active\_record’

class Catalog \< ActiveRecord::Base  
set\_table\_name “catalogs”  
end

# ActiveRecord::Base.establish\_connection( :adapter =\> “mysql”, :host =\> “localhost”, :database =\> “mydatabase”, :username =\> “root”, :password =\> )

Please help me to figure out the reason for the error and give your  
valuable suggestions.

Thanks in advance.  
Ravi

---

<div class="post-metadata">

**Author:** ![ponravikumar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/9de0a6/32.png) [@ponravikumar](https://www.ruby-forum.com/u/ponravikumar)\
**Post date:** [July 21, 2008, 1:33pm UTC](https://www.ruby-forum.com/t/syntax-error-unexpected/143639/2 "2008-07-21T13:33:11Z")

</div>

this line

ActiveRecord::Base.establish\_connection(  
:adapter =\> “mysql”,  
:host =\> “localhost”,  
:database =\> “mydatabase”,  
:username =\> “root”,  
:password =\>  
)

should have some value for the :password thing.  
either use  
:password =\> nil  
or  
:password =\> “”

---

<div class="post-metadata">

**Author:** ![ponravikumar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/9de0a6/32.png) [@ponravikumar](https://www.ruby-forum.com/u/ponravikumar)\
**Post date:** [July 21, 2008, 2:05pm UTC](https://www.ruby-forum.com/t/syntax-error-unexpected/143639/3 "2008-07-21T14:05:25Z")

</div>

Thorsten M. wrote:

> this line
> 
> ActiveRecord::Base.establish\_connection(  
> :adapter =\> “mysql”,  
> :host =\> “localhost”,  
> :database =\> “mydatabase”,  
> :username =\> “root”,  
> :password =\>  
> )
> 
> should have some value for the :password thing.  
> either use  
> :password =\> nil  
> or  
> :password =\> “”

Hi,  
After I changed the above modification in the model,  
I am getting the following error.

Access denied for user ‘root’@‘localhost’ (using password: NO)

This is my database.yml content

development:  
adapter: mysql  
encoding: utf8  
database: mydatabase  
username: root  
password: password  
host: localhost

The password also set as ‘password’ for the database,  
eventhough i gave the password I couldn’t get the out put.  
what changes shoule be made.

Thanks in advance,  
Ravi

---

<div class="post-metadata">

**Author:** ![ponravikumar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/9de0a6/32.png) [@ponravikumar](https://www.ruby-forum.com/u/ponravikumar)\
**Post date:** [July 21, 2008, 3:08pm UTC](https://www.ruby-forum.com/t/syntax-error-unexpected/143639/4 "2008-07-21T15:08:19Z")

</div>

Hi,  
Just check this…  
ActiveRecord::Base.establish\_connection(  
:adapter =\> “mysql”,  
:host =\> “localhost”,  
:database =\> “mydatabase”,  
:username =\> “root”,  
:password =\> “”;  
)

I hope this will work.

---

<div class="post-metadata">

**Author:** ![ponravikumar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/9de0a6/32.png) [@ponravikumar](https://www.ruby-forum.com/u/ponravikumar)\
**Post date:** [July 22, 2008, 6:44am UTC](https://www.ruby-forum.com/t/syntax-error-unexpected/143639/5 "2008-07-22T06:44:25Z")

</div>

srinivas reddy wrote:

> Hi,  
> Just check this…  
> ActiveRecord::Base.establish\_connection(  
> :adapter =\> “mysql”,  
> :host =\> “localhost”,  
> :database =\> “mydatabase”,  
> :username =\> “root”,  
> :password =\> “”;  
> )
> 
> I hope this will work.

Hi,  
I tried with the above changes…  
still I am having the problem…

herewith I attached the application codes  
I am using.

Please any one help me out this…

Thanks in Advance,  
Ravi

---

<div class="post-metadata">

**Author:** ![ponravikumar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/9de0a6/32.png) [@ponravikumar](https://www.ruby-forum.com/u/ponravikumar)\
**Post date:** [July 22, 2008, 9:44am UTC](https://www.ruby-forum.com/t/syntax-error-unexpected/143639/6 "2008-07-22T09:44:10Z")

</div>

On Jul 22, 5:44 am, Ravikumar P. \<rails-mailing-l…@andreas-  
[s.net](http://s.net)\> wrote:

> > I hope this will work.
> 
> Hi,  
> I tried with the above changes…  
> still I am having the problem…

Get rid of that semicolon. Putting the mysql connection stuff in the  
model class is a bit odd.

Fred

---

<div class="post-metadata">

**Author:** ![ponravikumar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/9de0a6/32.png) [@ponravikumar](https://www.ruby-forum.com/u/ponravikumar)\
**Post date:** [July 22, 2008, 10:09am UTC](https://www.ruby-forum.com/t/syntax-error-unexpected/143639/7 "2008-07-22T10:09:54Z")

</div>

On Jul 21, 1:05 pm, Ravikumar P. \<rails-mailing-l…@andreas-  
[s.net](http://s.net)\> wrote:

> Access denied for user ‘root’@‘localhost’ (using password: NO)
> 
> This is my database.yml content
> 
> development:  
> adapter: mysql  
> encoding: utf8  
> database: mydatabase  
> username: root  
> password: password  
> host: localhost

You’re not using database.yml because for some reason you’re  
establishing the connection by hand in catalog.rb. If you’re going to  
go that route then the call to establish\_connection must contain valid  
credentials (check them in another mysql client first)

Fred
