Questions tagged [mysql]

MySQL is a widely popular and accessible Relational Database Management System (RDBMS) that operates on the Structured Query Language (SQL). It should be noted that this designation exclusively applies to MySQL and not other databases like SQL Server or SQLite, each of which possesses their own unique SQL dialects for managing data. While seeking assistance, it is crucial to mention the specific version of the server being used in order to accurately address any potential issues as capabilities can vary significantly between versions 5.x and 8+.

"Although AJAX isn't functioning properly, the traditional form submission method is still operational

Does anyone know why this AJAX request is not sending the required data? The request is successful and triggers an alert, but no data is being sent. A standard ('#formid').submit function works, but it causes a page refresh. I need to achieve a non-refr ...

What is the correct way to designate a column as tinyint(4) using the Sequelize ORM framework?

I am in the process of defining my table with the following structure: CREATE TABLE `test` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `o_id` int(11) unsigned NOT NULL, `m_name` varchar(45) NOT NULL, `o_name` varchar(45) NOT NULL, `customer ...

Incorporating JSON objects into MySQL through a For Each loop - Checkbox Selections

My attempt to update the table (auth_users) with checkbox values using QueryBuilder and the provided code is not functioning correctly for the checkboxes on my form. I suspect that the issue lies in $key, "'".$value."'" not matching the DB field ...

A function that produces the accurate result in one specific scenario but fails to do so in all other

After conducting tests using the function below, I have come across a strange issue. When testing with the name "admin", it correctly returns an associative array with all the appropriate columns and values. However, for any other name entered, the query s ...

Error: Unable to access the `insertUsername` property as it is not defined

When I attempt to submit the login form created by the new.ejs file, instead of being redirected to the expected page, I am encountering an error message that reads: Cannot read property 'insertUsername' of undefined This same error message is also bein ...

Errors in SQL syntax are being triggered by MySQL prepared statements

When I attempt to use prepared statements for my SQL insert query, an error in the syntax is returned. I decided to test the query using PHPMyAdmin and substituted the placeholders with actual values. Surprisingly, the query worked perfectly, leading me t ...

Sending PHP emails may encounter issues when there is a URL link enclosed in an anchor tag within the email body

There seems to be an issue with sending emails when including an "a href" tag in the mail body. The email sends successfully when the 'a href' and 'www' tags are removed, but this affects the display of other content as per my requirem ...

Is it advisable to load 10,000 rows into memory within my Angular application?

Currently, I am in the process of creating a customer management tool using Angular.js that will allow me to directly load 10,000 customers into the $scope. This enables me to efficiently search for specific data and manipulate it without the need for serv ...

Tips for showcasing multiple tables based on certain criteria

Hey there, I'm currently working on an inventory page where I want to display multiple tables based on department values. The goal is to have each department in its own table instead of all merged into one. It would definitely make the page easier to nav ...

Display the count result in MySQL

I am attempting to display the results of a MySQL query in PHP. Here is the code I have used: $example = mysql_query("SELECT count(*) as text FROM table WHERE name = '$name'"); $qtd = mysql_num_rows($example); while($data = mysql_fetch_array($qtd)){ $co ...

Unable to access information through ajax when connecting to mysql database

Having a code that can add, edit, delete and view is good. When all the codes are put together in one file, it works fine. However, wanting to have it separately poses a problem with the "View" part. Despite trying to search for a solution, the functionali ...

Applying inline styles in PHP using if/else conditions

I want to customize the appearance of my table based on the status of each entry. Specifically, Completed = Green & Pending = Orange This involves PHP code that retrieves data from a MySQL database. $query = mysql_query("SELECT * FROM cashouts WH ...

Utilizing node.js for continuous polling in order to retrieve real-time database updates

I recently made the switch from Java server pages to Node JS in order to utilize server push technology. My goal is to create a straightforward application that sends data to users whenever a new record is inserted into a MySQL database. The database nam ...

What is the best way to assign an array as a parameter to a stored procedure in MySQL?

Having trouble passing an array as a parameter to my stored procedure and not getting the expected result. I'm attempting to send a list of emails and IDs from a view upon button click to a controller. Then trying to retrieve data from a database by passi ...

What is the best way to eliminate double quotes from multiple variables that combine to form a single string when exporting array variables to a csv file?

$fetchData = "SELECT * FROM members"; if (!$outputResult = mysqli_query($connection, $fetchData)) { exit(mysqli_error($connection)); } $usersList = array(); if (mysqli_num_rows($outputResult) > 0) { while ($rowsFetched = mysqli_fetch_assoc( ...

When new emails are added to the database, only the details of one email are inserted into the database

My journey with stackoverflow developers led me to successfully complete my first task, which involved creating an incoming email insert to the database query. Here is the code I used: #!/usr/bin/php -q <?PHP /* connect to gmail */ $hostname = '{exa ...

When searching through a MySQL stored procedure using Node.js, a null row is returned if no records are found by the

In my NodeJS application, I am using the MySQL library to call a stored procedure in MySQL. However, when the stored procedure does not return any matching records, the library returns an object with key values set to null. The following is the Stored Pro ...

Which database is favored by Node.js developers, PostgreSQL or MySQL?

Postgres boasts a wide range of features and has been successfully utilized by platforms such as Instagram, among others. On the other hand, MySQL has garnered a larger user base and has been implemented on popular sites like Facebook and Quora. How do the ...

Is mysql(i)_real_escape_string a reliable method for ensuring data safety?

function CustomQuery() { $arguments = func_get_args (); if (sizeof ($arguments) > 0) { $query_string = $arguments[0]; for ($index = 1; $index < sizeof ($arguments); $index++) $query_string = preg_replac ...

Creating a feature that allows users to edit the order of items within a MySQL

I am working on a project where I need to display a table of items that can be added, deleted, and reordered by the user. Initially, I planned to store these items in a MySQL database with an order column in the table. However, I realized this method is in ...

Executing PHP code from a list item

On one of my website pages, I have a list that functions as a delete button. However, I am interested in making it so that when a user clicks on the delete option, a php script is triggered - similar to how a submit button works. Below is the list structu ...

Query access in Laravel Model file

In my User.php file, I have defined a relation and a function: class User extends Model { public function children() { return $this->hasMany(self::class, 'level1_user_id') ->select(['id', 'first_name', 'last_name', 'level1 ...

Uncovering the Secrets: Extracting Data from a Custom MySQL Table for Magento's Adminhtml Grid Table

I'm currently running Magento 1.9.0.1! At the moment, I am developing a custom Magento extension where I need to display data from a custom MySQL table in an HTML grid table on a custom page. Here are all the files that I have created to accomplish this: ...

Is there a way to use axios in Vue and Laravel to easily upload both an image file and data object?

I'm having trouble uploading an image as well as additional text and numeric data fields to a MySQL database using Vue, Laravel, and Axios. Below is the code for the method in my Vue component: addProductToShop() { const imageData = this.$refs.inp ...

A critical error occurred: Unhandled Exception - Attempting to call a method on a null object in the directory C:xampphtdocsshopindex.php

Help needed with code troubleshooting - encountering error message Error message: Fatal error: Uncaught Error: Call to a member function query() on null in C:xampphtdocsshopindex.php:11 Stack trace: #0 {main} thrown in C:xampphtdocsshopindex.ph ...

Fetching information through AJAX in NodeJS and saving it in a database

I am facing an issue with retrieving data from the client side in my NodeJS application. I have prepared JSON data on the client side, which can be viewed in this codepen link. On the server side, I am attempting to receive this data from the client: var ...

Setting Collation and Charset in Node.js Models using Sequelize and Mysql

Currently, I am utilizing sequelize with node and node-mysql in my project. When creating models using the sequelize-cli, the resulting code appears as follows: 'use strict'; module.exports = function(sequelize, DataTypes) { let songs = seq ...

Uploading Multiple Files with Base64 Encoding in PHP

I am looking for a way to store images in a database and retrieve them using base64 encoding/decoding. Can anyone guide me on how to achieve this? Here is the HTML code: <form method="POST" action="add_script.php" enctype="multipart/form-data"> ...

What's the deal with phpMyAdmin?

I'm at a loss for what happened. I simply set a password for one of my registered accounts and this error message popped up. What should I do? Error MySQL said: Documentation 1045 - Access denied for user 'root'@'localhost' (us ...

Error occurred when attempting to submit form data to MySQL database

I am facing an issue with my form submission. I have created a form to insert values into a MySQL database, but when I click the submit button, the database is not getting updated. I'm not sure where I went wrong in my code. <html> <head> ...

Converting Time from a String to Numerics in PHP and MySQL

Currently, I'm working on creating a visual representation of drill times for my project. Within the database, drill durations are stored as Time fields. When retrieved, the times are in MM:SS format (e.g., 05:30). The graphing package I've selected (jpgr ...

What steps can be taken to enable users to draw a path on a Google Map?

I'm working on a new project for a Facebook app that will allow users to map out their marathon route using Google Maps. I plan to utilize mySQL database records to store fixed points along the path (such as specific locations based on latitude and longitu ...

Utilizing functions on combined tables with Sequelize

Currently, I am attempting to execute the TIMESTAMPDIFF() function on a column in a joined table. My current implementation looks like this: Project .findAll({ include: [Note, Link], attributes: [ [sequelize.fn('TIMESTAMPDIFF', ...

Verification of User Status

I am struggling with a small script that is supposed to check the database for values 0 or 1. Even after attempting different methods like using row count, I still can't seem to get it to work correctly. public function checkStatus($id){ $stmt = ...

Encountering an unknown error while trying to perform a build using sequelize and express

When trying to build with sequilize after retrieving data from a form and posting it, an error is encountered: TypeError: Cannot read property 'build' of undefined index.js router.post('/register', function(req, res){ var name = req.body.name; var ...

The functionality of Ajax is not supported on iPhone Safari browsers

I have encountered an issue where my ajax function works perfectly in Firefox, but it fails to work on my iPhone. Initially, I suspected the XMLHttpRequest was causing the problem, but that does not appear to be the case. I can confirm that the PHP script ...

Tips for effortlessly adding a JSON object to a table

Let's imagine we have a table structured like this: id| name | family ---+------+--------- 1 | iman | marashi 2 | mike | ... 3 | john | ... 4 | | Now, we also have a JSON object that we want to add to the table: {"name ":"will","family":"smith ...

The error message "PDOException: driver not found" indicates that the driver needed

Whenever I try to connect to a MySQL database on localhost using PHP, I encounter a PDOException stating that the driver could not be found. $this->conn = new PDO("mysql:host=" . $this->host . ";dbname=" . $this->db_name, $this->username, $thi ...

Create a payment invoice using the power of AJAX, jQuery, PHP, and MySQL

Having issues with my bill calculation. When adding multiple products, the price of all products appears to be the same. I'm unable to calculate the total correctly and struggling to fix this. Please review my code and provide insights. bill.php <?php ...

Laravel Joining Techniques

When querying data from the courses and students tables (which have a foreign key relation), I encounter an issue where the name column is the same in both tables. When retrieving the data, only the course name is displayed but I need to display both the s ...

Switching timezones in PHP programming

Something doesn't quite add up. Let's consider a scenario where my server is set to America/Toronto timezone for storing date/time information. Now, if I need to convert the time for someone on the west coast, I use this code snippet: $timestamp ...

Adding JSON arrays into a MySQL table with Python

I am currently facing issues with inserting values into a MySQL table called "section". This table consists of 5 columns, including one integer, one text, and three JSON arrays. The JSON array values are stored in variables 's', 'l', an ...

Retrieve a numeric value from a MySQL database table, perform a multiplication operation on it, and then

Hey there, I'm new to PHP MySQL and in need of some assistance: I currently have a Table in my MySQL database structured like this: Number1 | Number2 | Calculate  8    | 9    |      &nb ...

Acquiring administrative authorization upon user login with PHP

I have developed a registration form and a login form using PHP. However, whenever I run this code, it displays the message "invalid username" when the username is invalid, or it says "your account isn't approved by admin yet." Can anyone please guide me o ...

Retrieve data from MySQL using a count query and convert the results into a JSON format

In my table, there is a column with datetimes and corresponding IDs. +----+---------------------+ | id | datetime | +----+---------------------+ | 0 | 2016-09-02 12:13:13 | | 1 | 2016-09-02 10:16:11 | | 2 | 2016-09-05 11:03:23 | | 3 | 2016- ...

How can I use UNION in MySQL or MySQLi to select data without any NULL values and order the results in a specific

I am faced with a challenge in my coding project... $query = "SELECT {$selections} FROM {$table_1} UNION ALL SELECT {$selections} FROM {$table_2} UNION SELECT {$selections} FROM {$table_3} UNION SELECT {$selections} FROM {$table_ ...

Import data from a local file using SQL

Here is an example of how my data appears: company_name,brand_name,product_name,usage_annotation,organic_standard ASB Greenworld Ltd.,ASB Greenworld Ltd.,Organic Garden Manure,,"COS,NOP" ASB Greenworld Ltd.,ASB Greenworld Ltd.,Organic Seed & Herb Soil ...

Implementing efficient checking of data uniqueness during insertions and updates

In my staff table, I want to ensure that the values in two columns - staff_code and staff_name - are unique. | staff_id | staff_code | staff_name | |-------------|------------|------------| | 1 | MGT | Management | | 2 | IT ...

PHP MySQL Table with a Date Range Filter

As someone who is new to PHP, I have a question. How can I set up a date range filter? I've looked at tutorials, but they haven't worked for me. I do have some code, but it doesn't include any functions. I want to implement this in a CRUD table. <fo ...

How can I adjust the format of a timestamp field from the database to adhere to Dutch locale conventions?

I am attempting to convert a timestamp string from the database into a Dutch locale format that resembles: Maandag 2 juli 2013 My approach was as follows: <?php setlocale(LC_ALL, 'nl_NL'); echo strftime("%A %e %B %Y", mktime($vac->gepl ...

using javascript to retrieve php variables

After creating a webpage, setting up Apache2 on an Ubuntu server to access it over the internet, and installing PHP5 and MySQL, I encountered issues with accessing database information on my page through a .php file. Despite having a file named test.php th ...

Retrieving specific user data from a MySQL database in PHP can be achieved by using the logged-in user's information as

I've been struggling to retrieve specific user data for the logged-in user. While I can fetch all data with my current code, I need to narrow it down to just one user. I attempted using WHERE username="$username" and various other approaches, but non ...

Establishing a Secure Connection between PHP Server and Amazon AWS MySQL Server

Currently, I have set up two servers on Amazon AWS. One server is dedicated to running PHP while the other handles MySQL. Accessing the MySQL database through my terminal and MySQL Query Browser has proven successful. However, I am facing challenges in es ...

Caution: mysqli_connect(): (HY000/1045): Unauthorized access for user 'root'@'localhost' (using password: NONE)

PHP Notice: mysqli_connect(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: NO) in G:PleskVhostspeacewithoutlimits.orghttpdocsadminincludesconnect.php on line 8 <?php $servername = "local ...

Using PHP to combine MySQL tables and then displaying the results in a neatly organized JSON

Struggling to merge data from two MySQL tables in my PHP script and transform it into JSON for use in our internal art team app. This tool is exclusively designed for making edits to products created by our company. The main goal is to generate a product ...

"Utilizing the power of Node.js to perform SQL queries with

I'm having trouble with this SQL query that uses INNER JOIN. The query is returning an error. connection.query("SELECT caracavis.caracname FROM caracavis WHERE firstcaturl ='" + req.body[0].firstcatname + "' AND secondcaturl = '" + r ...

Is information automatically included in my query by default?

I've been attempting to retrieve some data from one of my databases, but every time I execute the query, an error pops up: An exception occurred while rendering a template ("SQLSTATE[42S22]: Column not found: 1054 Unknown column 'users_fri ...

Guide on calculating the quantity of rows in a Json data set

How can I determine the number of rows where my ID is present in one of the fields, which are stored as JSON objects: { "Monday":{"1":"15","2":"27","3":"74","4":"47","5":"42","6":"53"}, "Tuesday":{"1":"11","2":"28","3":"68","4":"48","5":"43","6":"82"} ...

How to retrieve data as a dictionary instead of a tuple using MySQL's fetchall() method

I have a table with the columns id, col1, col2, and col3. When I ran the query, this is how it was executed: cur.execute(query) row = cur.fetchall() Is there a way to store the data in the variable row inside a dictionary so that I can pass this result t ...

Suggestions for enhancing the functionality of this code by incorporating an additional dynamic chained selection box

Currently, I am utilizing a plugin offered by CSS-Tricks to create two chained select boxes using PHP, jQuery, and MySQL. I am contemplating the idea of introducing an additional box that will be dependent on the selections made in the first and second box ...

Looking to Connect 3 Tables Using Varying Columns

product_to_category p2c has 2 columns: category_id product_id There may be multiple entries for each product, so we need to use MAX (category_id). category_to_google c2g has 2 columns: category_id google_id google_category gc has 2 columns: google_id ...

`To adjust stock levels in SQL when they are higher than the specified quantity needed`

I need a way to update the stock of each number only if all numbers have enough stock. Currently, the issue is that even if one number is out of stock, it still updates other numbers. I want it to update only when all numbers have sufficient stock. For ex ...

Issues with assigning values to a variable in a PHP/MySQL prepared statement?

My PHP code contains a prepared statement with joins that is not assigning values to one of its variables: $dbRating = "x"; $dbFavDate = "x"; if($stmt = $dbcon->prepare(" SELECT i.*, u.username, r.rating, f.date_favorited FROM image i ...

Troubleshooting Issue: Data not appearing on Angular frontend when fetching from Laravel API

Utilizing Laravel for the back end and Angular for the front end development. The code segments related to Angular can be found in employee.component.ts file: import { Component, OnInit } from '@angular/core'; import { DataService } from 'sr ...

Avoid multiple clients from re-evaluating Redis values simultaneously

Imagine a scenario where our website has important counters on every page, making it heavily loaded. These counters are stored in Redis keys that automatically expire in an hour. Within our code, we have a check to see if a key containing a counter exists ...

Receiving an UNDEFINED INDEX error when trying to send data from an HTML form to a

I've created an HTML form that is styled using CSS for weekly work data entry. <form action="wwinsert.php" method="post"> <fieldset> <legend>Weekly Work</legend> <p><label class="lab1" for="StoreNumber">Store:</label ...

Troubleshooting Issues with Retrieving Android Data from MySQL Database using PHP and JSON

Even though I have encountered this question multiple times on stack overflow, I have tried all the solutions provided and none of them seem to work for me. I am attempting to display data in a List View. The data is stored in JSON format and it appears t ...

Received a 'PDOException' error stating 'SQLSTATE[HY000] [2002] Connection timed out' while attempting to establish a connection with Google Cloud SQL

Hello everyone, I have been attempting to establish a connection with Google Cloud SQL from an external website. I have authorized the server's IP in Google Cloud under Instance -> Access Control -> Authorization The instance has been assigned an IP ad ...

PHP and MySQL: Retrieve data based on user-specified time zones

Within my database, there is a table that tracks hits at different times. An example of this table looks like: id | datetime | ... ----------------------------------- 1 | 2014-05-30 15:19:00 | ... 2 | 2014-06-01 12:14:00 | ... 3 | ...

What is the best way to execute a function that retrieves data from a MySQL query and then sends it back as a result in Express.js?

How can I refactor my code to efficiently call a function that returns the result of a MySQL query and send it back in an Express.js response? I am attempting to streamline my SQL queries by exporting them into individual functions to eliminate duplicatio ...

What is the proper way to structure the DATETIME format when making an API request to mySQL?

Frontend code: import React, { Component, useState, useEffect } from "react"; import Navbar from "../Navbar/Navbar.js"; import BarChart from "../BarChart/BarChart"; ... Backend code: //set up express server const express = require("express"); const app ...

Leveraging passport.js and direct SQL queries for authentication purposes

Currently tackling a project with an issue that needs resolving. I am looking to integrate user login logic utilizing the Passport API, but struggling to grasp its functionality, especially when implementing it using plain SQL queries. While scouring thr ...

Unable to present the information due to a codeigniter error in retrieving the data

Encountering an issue where the data cannot be displayed and it's showing an error message of undefined variable: avg. Below is the script being used: The controller function: public function rate_config() { $rt = $_POST['hasil_rating']; ...

What is the most effective approach for thwarting XSS attacks?

What's the best approach for preventing XSS attacks? I'm currently working on some code. Will this line of code effectively protect against XSS attacks, or should each element be parsed with 'strip_tags'? Any suggestions would be greatly appreciated. $xs ...

Troubleshooting: Error Connecting PHP to MySQL on Localhost Using Dreamweaver

Attempting to access my localhost database, which I created with phpMyAdmin, from Dreamweaver has been a bit challenging. While I successfully set up the site and server, I encountered an issue when trying to select the database in Dreamweaver. The error m ...