Working with MySQL database in AngularJS application to save and fetch information

For a personal project, I've been using AngularJS to develop a quiz website. I have a web hosting plan with 123-reg.co.uk and successfully set up a MySQL database to store the scores of people who take the quiz.

This will allow me to create a scoreboard feature on my website. My goal is to include two functions on my site: one that retrieves scores and another that posts new scores. I understand that I'll need to use PHP to accomplish this, but I'm unsure where to begin since I am not very experienced with MySQL databases or PHP.

If anyone can offer some guidance or tips, I would greatly appreciate it as I navigate through this learning process. I came across this guide on connecting to a MySQL database from 123reg.co.uk, but I'm still facing challenges.

Thank you, Simon

Answer №1

The tutorial you referred to is outdated, as it relies on the deprecated mysql_connect function in PHP 5.5.0 and removed in PHP 7.0.0. It would be beneficial for you to find a more current tutorial that utilizes mysqli or PDO.

In addition, it is important to familiarize yourself with security considerations before proceeding with this task. Implementing an insecure script can lead to serious issues.

There are several PHP frameworks available that provide secure and easy solutions for these tasks. I suggest looking into the Laravel Framework. While not designed for beginners, with some knowledge of PHP object-oriented programming and MySQL (or any SQL database supported by Laravel), you can achieve your goals.

You may also benefit from visiting Laracasts, a helpful website offering beginner-friendly tutorials on Laravel.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What would the equivalent Javascript implementation look like for this Python code that decodes a hex string and then encodes it to base64?

Currently, I am facing the challenge of transferring code from a Python script that decodes and encodes a string using a series of decode() and encode() functions. In Python, the code appears as follows: import codecs input = '3E061F00000E10FE' ...

The property cannot be set because it is undefined in nodejs

var list = [ { title : '', author : '', content : '', } ] router.get('/japan',function(req,res){ var sql = 'select * from japan'; conn.query(sql,function(err,rows,fields){ for(var i = 0 ; ...

Display only the posts of the logged-in user in a React application

I need assistance with a React return that displays only the posts of each logged-in user. Currently, my code loads all posts from all users and shows only the posts from the user who is currently logged in. However, the other posts still take up screen s ...

Choose the column when there are no entries in the translation table

Here are the details of the two tables I have: features ╔════╤═════╗ ║ id │ value ║ ╠════╪═════╣ ║ 1 │ A ║ ╟────┼───────╢ ║ 2 │ B ║ ╟──── ...

Errors found during compilation when running the npm start command

After choosing to develop an app with React using VS Code, I initiated the process by running npm create-react-app ./, which was a success. However, when I proceeded to execute the command npm start, it resulted in compilation errors related to files suc ...

Running a command once the forEach loop is completed in Angular

Within the HTML, I have a function that is triggered by an ng-click: vm.items = []; vm.moveItems = function() { angular.forEach(vm.items, function (item) { $http({ method: 'PUT', url: &apos ...

How can we determine the nL and nH values using an ESC/POS command?

Looking to adjust the printer's head position using ESC / pos commands: ESC $ command sets the absolute horizontal position ESC $ nL nH Trying to figure out how to calculate the values for nL and nH? ...

Ways to access a conditional rendered ref element in Vue using v-if

I have a specific element that is conditionally rendered using v-if="isLogged" when a user is logged in: <div v-if="isLogged" class="chatBlock" ref="chat" ></div> The issue I'm facing is trying to retrieve the scroll height of the ...

Configure webpack to source the JavaScript file locally instead of fetching it through HTTP

Using webpack.config.js to fetch remote js for Module Federation. plugins: [ new ModuleFederationPlugin({ remotes: { 'mfe1': "mfe1@http://xxxxxxxxxx.com/remoteEntry.js" } }) ], Is it possible to incorporate a local JS ...

Steps to successfully set up a React application without encountering any installation errors

Hey everyone, I've been trying to install React on my system for the past two days but keep encountering errors. Initially, I used the commands below to install the React app and it worked smoothly: 1. npm install -g create-react-app 2. create-react- ...

Verify the dates in various formats

I need to create a function that compares two different models. One model is from the initial state of a form, retrieved from a backend service as a date object. The other model is after conversion in the front end. function findDateDifferences(obj1, ...

Aligning a navigation bar with a hamburger menu in the center

I recently implemented a hamburger menu with some cool animations into my site for mobile devices. Now, I am facing the challenge of centering the menu on desktop screens and it's proving to be tricky. The positioning is off, and traditional methods l ...

Item does not connect

Recently, I've been diving into the world of hooks but encountered an issue with objects. It seems like useState is not recognizing my object as intended and I'm unable to access the second value. function App() { const [fullName, setFullName] ...

I am attempting to access an Angular variable using JavaScript, but unfortunately, I am encountering some issues

I'm currently implementing the following code: window.onload=function(){ var dom_el2 = document.querySelector('[ng-controller="myCtrl"]'); var ng_el2 = angular.element(dom_el2); var ng_el_scope2 = ng_el2.scope(); console.log ...

Displaying a PHP variable on the console through the power of jQuery and AJAX

I'm attempting to display the value of a PHP variable in the browser's console using jQuery and AJAX. I believe that the $.ajax function is the key to achieving this. However, I am unsure about what to assign to the data parameter and what should ...

How can one determine the existence of a collection or sub-collection?

Can you verify the presence of a sub collection in Firestore using Node.js? I have been utilizing doc.exists for documents, but I now require a way to determine if a sub collection exists within a document before proceeding with writing data. ...

Modify according to chosen criteria to identify copies that are inferior in size

In my database, I have a table named content that includes the fields: id (primary key), title, alias, state, and hits. There are multiple duplicate records in this table where different ids exist but both the title and alias fields are the same. The "sta ...

Every click will nudge the square to the right

I have a square that should move 100px to the right when clicked, but on the next click it moves back to the left. How can I resolve this issue? On JSFiddle, the code works fine. However, when I try to run it in Chrome, I get an error message: Cannot re ...

The ReactJS Material Table Tree mode experiences delays when new row data is introduced

My Reactjs app utilizes the material-table widget within a component: render() { return ( <div> <Row> <MaterialTable title="Mon équipement" style={{ width: "100%", margin: "0%" }} ...

Utilizing a factory as the data source in angular-datatables leads to unexpected errors

Is it possible to use a factory as a source data in angular-datatables? Basically, I want to retrieve data in a variable and use it as the data source. UPDATED (06/22/2016) This is my updated factory: statisticsModule.factory('globalFactory&apos ...