• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Working with database

Explorer ,
Mar 17, 2024 Mar 17, 2024

Copy link to clipboard

Copied

Okay, I have never worked with coldfusion database before. Here is the deal. I have a website structure like this:

 

/root

    /Register/index.cfm

    /MembersOnly/DatabaseFiles/users.sqlite

I am trying to access this users.sqlite db from index.cfm file but I keep getting error. 

 

This is my code: 

<cfset request.pageTitle = "Registration">

<!--- Define the relative path to your SQLite database file --->
<cfset database_path = "../MembersOnly/DatabaseFiles/users.sqlite">

<cfif IsDefined("form.username") and IsDefined("form.email")>
    <!--- Establish Connection to SQLite Database --->
    <cfquery name="insertUser" datasource="#database_path#">
        INSERT INTO users (username, email)
        VALUES (
            <cfqueryparam value="#form.username#" cfsqltype="CF_SQL_VARCHAR">,
            <cfqueryparam value="#form.email#" cfsqltype="CF_SQL_VARCHAR">
        )
    </cfquery>

    <!--- Check if the registration was successful --->
    <cfif insertUser.recordCount>
        <p class="style1">Registration successful!</p>
    <cfelse>
        <p class="style1">Registration failed. Please try again.</p>
    </cfif>
</cfif>

<p align="center" class="style2">REGISTRATION FORM</p>
<p class="style1">In Development process</p>

<div class="reg__container">
    <form class="form__container" method="post">
        <label class="form-label" for="username">Username:</label>
        <input class="form-input" type="text" id="username" name="username" placeholder="Enter your username" required>

        <label class="form-label" for="email">Email:</label>
        <input class="form-input" type="email" id="email" name="email" placeholder="Enter your email" required>

        <div class="form-checkbox-container">
            <input class="form-checkbox" type="checkbox" id="subscribe" name="subscribe">
            <label class="form-label" for="subscribe">Agree to out <a href="#">terms</a> of use.</label>
        </div>
        <button class="form-button" type="submit">Submit</button>
    </form>
</div>

The error I am getting is: datasource [../MembersOnly/DatabaseFiles/users.sqlite] doesn't exist

 

I am confused how this works? 

Screenshot_1.jpg

Views

1.0K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 17, 2024 Mar 17, 2024

Copy link to clipboard

Copied

Aleksandar, that screenshot shows us you're using Lucee. To be clear, that's not ColdFusion: it's an open source alternative cfml engine. I'm not saying it's bad to use, nor am I saying it's wrong to ask about here. But it can be important to know which you're using, as they do have differences, especially about admin configuration, database integration, and more. 

 

So I'm just saying first that it could be important to identify here when you're using it, as this is indeed the Adobe CF forums. We'd presume folks use it, when asking here. (And you can't presume people reading one post of yours would see previous ones.) 

 

But second, note also that you could ask your questions on the lucee forums, which are at dev.lucee.org. There, folks would presume you're using Lucee, which again could be important for some challenges. 

 

Finally, as for this one, note there is no "coldfusion database". You're using sqlite. I'm not sure about using Lucee with it, and I've not used sqlite at all myself.

 

Maybe someone else here may have answer for you, but again the folks at the Lucee forum will set you right.

 


/Charlie (troubleshooter, carehart.org)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 18, 2024 Mar 18, 2024

Copy link to clipboard

Copied

Ok, okay, sorry for this. I am helping a friend out and I am very very little familiar with lucee and CF. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 20, 2024 Mar 20, 2024

Copy link to clipboard

Copied

LATEST

You are getting the error because you have entered a path (../MembersOnly/DatabaseFiles/users.sqlite) as the name of the datasource. What you should have done is:

  1.  Define a datasource in the Administrator or in the Application file.
  2.  Use the datasourceName so defined as the value of the datasource attribute in the above code.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation