views:

278

answers:

3

OK, Ive got my site all up - just not working. ahah. I need (I think) the correct code for a connection string to my database etc. I'm using ColdFsuion and Mysql. My code for the connection string is as follows:

<CFQUERY 
  NAME="cfGossip" 
  DATASOURCE="mysqlcf_bridgettip" 
  USERNAME="<bridgettip>" 
  PASSWORD="<*******>"
>
</CFQUERY>

My DNS on my hosting plan is, well I think is - mysqlcf_bridgettips and on my ColdFusion is cfGossip. I'm not sure which one to use, or if it's even one of them...? It says the error is there when I try access my index.cfm page.

The error over all is :

500 - Internal server error.
There is a problem with the resource you are looking for, and it cannot be 
displayed.

Is it the connection string that is wrong? I would really love any help at all - rewriting my string etc.

+2  A: 

Typically ColdFusion is easier to handle by adding datasources via the ColdFusion Administrator: See Adding Data Sources for ColdFusion.

artlung
I have one in ColdFusion - a MySQL 4/5 - but does that mean I do not have to add any code in my application to connect to my database that i've uploaded to my hosting account? - also the server on my MySQL and ColdFusion id "localhost" should it be that same as my hosting account server:bridgettips.db.5452582.hostedresource.com? I changed them to give it a try - but it came back with an error...
Steven2304
@Steven: In the ColdFusion Admin, under data sources: Does the data source test succeed (there's a button to test the connection)? If it does, all you have to do in code is mention the configured data source name in `<cfquery>` tags. No username/password required.
Tomalak
A: 

My DNS on my hosting plan is, well I think is - mysqlcf_bridgettips and on my ColdFusion is cfGossip.

The coldFusion Administrator should have a datasource that contains your mysqlcf_bridgettips information (CF datasource name, database name, server IP and port, username/password). If you've named that datasource cfGossip in the administrator than your cfquery should look like:

<cfquery name = "variableNameOfYourQuery (ex. qUsers)" datasource = "cfGossip">

I put my username/password in my datasource in the administrator so I don't have it written in my code.

I believe CF5 was the only version of CF that allowed DSN-less connections that would require a "connection string".

Travis
A: 

if you cant access the coldfusion administrator and have no control panel to add a datasource you need to ask your host to add a datasource for you with a name. A datasource in this context is different from having the database created - its having the database "registered" with the coldfusion administrator so that it can be referenced via a datasource name

once the datasource is created you can hit it by adding the datasource attribute to the cfquery tag: cfquery name="myquery" datasource="mydatasourcename"

Diarmuid