Questions tagged [mysql]

MySQL is an open-source, relational database management system. If your PHP code uses MySQLi, use the MySQLi tag instead.

Filter by
Sorted by
Tagged with
0 votes
1 answer
36 views

PHP login codes suggestions

Now i have a fully functional PHP codes for login and registeration i was wondering if anyone could offer improvements to the code The code: Config.php: ...
Bebo's user avatar
  • 39
1 vote
1 answer
127 views

Follow up to Validation Script in PHP

So I've implemented the suggestions in Original question And now my code looks like this: ...
Bebo's user avatar
  • 39
1 vote
1 answer
88 views

PHP Validation script

The code below is modified slightly from the code in this previous post. I believe the code below could be improved and more secured but i don't know how so someone please show me how an improved ...
Bebo's user avatar
  • 39
0 votes
1 answer
87 views

SQL & PHP login method

My code is working however it seems to be using old outdated php version so less secure and I'm still new to programming so I'd be more than thankful if someone shows me how an improved updated and ...
Bebo's user avatar
  • 39
1 vote
1 answer
62 views

blog RESTFUL api with posts and comments

I built RESTFUL api for a blog using java and spring boot(without a frontend). What it does the code manages all the http methods on a post inside the blog and comments on that post. the post consists ...
Guy's user avatar
  • 177
-1 votes
1 answer
60 views

is my code protected against SQL injections?

im using spring boot and CrudRepository for my queries, the project is about posting content on a blog, so I have a post record with id, creator name, post name, the content itself likes and dislikes: ...
Guy's user avatar
  • 177
4 votes
3 answers
1k views

Count unique visitor using IP address and make sure that 24 hours has passed before incrementing the counter

I've created a unique page counter using a PHP script. Pages could be videos, images, publications, etc. Every time a new user views a page, I record the entry and increment the view counter. I cannot ...
Marco's user avatar
  • 217
1 vote
2 answers
60 views

backend Database authorization app using MySQL [V2]

here is my first virsion question: Is it good practice to have all my back end in one single file with all functions being static? ...
Guy's user avatar
  • 177
1 vote
4 answers
163 views

Is it good practice to have all my back end in one single file with all functions being static?

...
Guy's user avatar
  • 177
0 votes
0 answers
28 views

MySQL join query to link valuations with associated valuation tasks

...
Michael LB's user avatar
3 votes
1 answer
149 views

PHP MySQLi Wrapper Class For API

I've never had my code reviewed before, so I am taking this opportunity to see what can be improved with my coding style. I am still somewhat "new" to PHP, in the sense that I'm an old dog ...
Bellator's user avatar
  • 131
0 votes
0 answers
54 views

SQL: updating a variable number of columns in a row

Data coming from HTML form: several inputs that need to be entered into the database, any of which may be empty. How do you solve this task? My approach: check params, null if empty, than execute one ...
o0o0o's user avatar
  • 53
1 vote
0 answers
21 views

Use API data to ensure current product prices in database data then sort by price

Because I've waited until now to bother learning the magical JSON functions that modern MYSQL affords, I wonder if my code is optimally written and if there are cautions/limitations to be aware of. My ...
mickmackusa's user avatar
  • 8,534
3 votes
0 answers
77 views

Create table of yearly monthly temperatures from monthly data

I've got a series of tables with monthly data on USA regions over about 130 years, divided by either climate divisions (clim_div) or other federal standards (ncdc_fips). They all follow the same ...
DownrightBass's user avatar
-2 votes
1 answer
76 views

Preventing PHP SQL injection on login [closed]

I had a login code like this: ...
Bazim's user avatar
  • 19
1 vote
1 answer
239 views

Three way Eloquent relationship definition and saving in Laravel

I'm building a Laravel app (with Vue3 and InertiaJS), and I'm attempting to create relationships between three models: User Area WorkHours where WorkHours is the ...
wonder95's user avatar
  • 111
1 vote
1 answer
45 views

Find offers that can be matched with bids

I am working on a sql query for the following scenario: Get all available offers for registered demand (offers from profiles should not be from profile which had registered demand). After that get ...
Gleichmut's user avatar
  • 121
3 votes
1 answer
90 views

Company management app: Extracting data with JDBC and java.sql

I'm currently working on a company management system as a university project, and I have to get my hands in java.sql. I have come to struggle with extracting a ...
Thomas Herondale's user avatar
0 votes
0 answers
46 views

Can this database design be optimized? Two joins on large dataset

Given a table of video IDs ordered by review score, I'd like to return videos the user hasn't seen yet and aren't from a blocked author. Considerations Writes can be slow but reads should be fast to ...
N S's user avatar
  • 101
1 vote
0 answers
47 views

PHP PDO prepared statement with IN [closed]

Here's my code: ...
neubert's user avatar
  • 111
4 votes
3 answers
365 views

Queries to get products selected in multiple stores

Project description I'm making a website listing products. The listing goes as following (See here): Product name Shop name Price in that shop If the product appears multiple times in the table for ...
Alpha.Ars's user avatar
9 votes
5 answers
2k views

Weekly MySQL database backup

I haven't used Unix, etc. for 40 years, so I am a bit rusty. I need to back up the databases on my website(s) once a week and then retrieve them automatically from my development machine. So this is ...
Rohit Gupta's user avatar
4 votes
4 answers
474 views

Functions in PHP to run basic MySQL crud

I wrote a list of functions in PHP that I want to use in my pet project as an autoloaded file for all parts of the app. The purpose of these function is to shorten the code you write for MySQL queries ...
Syed M. Sannan's user avatar
0 votes
2 answers
103 views

Search between dates in a WP Query

In the posts I have a date field and a start and end date range. I need to query if it matches date or if it matches between the dates in the range. This Query works, but how can I optimize? ...
cRiSs rOcCa's user avatar
0 votes
0 answers
32 views

How to create a good database model in my task (I have a few tables for now)

I create a smaller app that has to be used for money transactions where it focuses on favor and expense from bank accounts (later I will expand other tables for admin, workers costs, credit ...
Perkone's user avatar
0 votes
2 answers
183 views

Version 2: Display visitor's number on your web page (changed code after getting answer for first version)

Version 2: Display visitor's number on your web page (changed code after getting answer for first version). The first version is here: Display visitor's number on your web page The "visitors&...
user avatar
0 votes
1 answer
211 views

Display visitor's number on your web page

Display visitor's number on your web page. The "visitors" table has only one column (visitor_count) and only one row. The column's initial value is 0. I know goto should not be used but then ...
user avatar
3 votes
1 answer
154 views

Proper PDO connection function

I am reviewing the database class for a live website. I am not sure if the current connect function is the best way to create a pdo object as it appears to create a new connection every time it is ...
jdf's user avatar
  • 31
4 votes
0 answers
77 views

A procedure that receives a letter and a number that shows for example : (A,3) A AA AAA

Make a procedure called paintletter, it receives two parameters, a letter and a number. it will have to paint on the screen lines with the specified letters starting with a letter and ending with as ...
Javier G.Raya's user avatar
3 votes
1 answer
44 views

MySQL procedure to extract a letter from a phrase

Create a function called GETLYRICS, which will receive as parameters a word of at most 15 letters and a number. It must return the letter of the position indicated in the number. My exercise is fine ...
Javier G.Raya's user avatar
0 votes
0 answers
40 views

Extract the divisors between dividing and divider

It turns out that I have to do a procedure called THEDIVIDERS which receives two numbers for parameters, in my case the parameter 1 is by dividing and the second divisor parameter. Statement : Make a ...
Javier G.Raya's user avatar
2 votes
1 answer
589 views

SQL query to find expenditures of employees who have exceeded their limit

I've 2 tables emp and expenditure. Emp: ID, NAME Expenditure: ID, EMP_ID, AMOUNT Each emp has a limit of 100 that he/she can ...
reiley's user avatar
  • 137
2 votes
1 answer
214 views

Optimization of laravel pivot table relationship

I have a pivot table called invite_riskarea which is designed as follows: This table stores the permissions that have a specific user (through an invite id) to ...
sfarzoso's user avatar
  • 137
-3 votes
1 answer
51 views

How to select lots of friends posts from database [closed]

...
The concise's user avatar
2 votes
1 answer
28 views

Shell script to backup db from mysql whether the mysql server is running in docker

I have written this shell script to backup MySQL database to disk. It works fine but I am not well proficient in shell scripting. So what do you think can it be improved? ...
Chang Zhao's user avatar
1 vote
2 answers
87 views

Having trouble deleting multiple queries (PHP, MYSQL)

I'm having trouble making WHERE IN query work, I was only able to make it work as a foreach loop. My payload looks like this: sku[]: BOOK0002 sku[]: BOOK0003 My ...
Metwesh's user avatar
  • 11
0 votes
1 answer
148 views

Is this session manager secure?

I'm looking for best practices for writing secure session managers. I'm making a table for the authorization token (UUID OR GUIDv4) with autoincrement, user_id, token, status (enum) then update status ...
Taa Lee's user avatar
  • 27
1 vote
1 answer
128 views

Validate avatar image

I want to know if that code is correct and readable. In class avatar the method getAvatar() validates the data. It checks if the field is not empty and if the photo extension is correct. If not, an ...
user254603's user avatar
1 vote
0 answers
55 views

Calculate time interval excluding breaks

I have a solution for a question I asked on SO: I am trying to create a database where I also need to find the time difference inside a record. However, timediff() ...
Memo Haldan's user avatar
0 votes
4 answers
467 views

table name column name from GET parameter

This is a function that reads a setting data from DB. ...
flow Stack's user avatar
2 votes
1 answer
245 views

PHP OOP: Configuring MySQL DB & query w/ Twig

I decided to up my PHP game and learn some OOP. I am re-building my website from procedural to OOP, but since I don't want to use a full framework I fiddle with some components. As a router I use ...
bender's user avatar
  • 21
0 votes
3 answers
702 views

url encoding and storing (JS, PHP, MySQL) [closed]

This question is about how best to encode, send and store information between JavaScript, PHP, and MySQL I am doing a GET request from HTML/JavaScript to my PHP server, which is then storing the data ...
ControlAltDel's user avatar
1 vote
3 answers
185 views

SQL query joining applications to categories

I do have large database and my query takes about 2s to complete on production environment which is kinda slow and would like to ask is there a space for improvement? My initial inputs are ...
Marius's user avatar
  • 119
0 votes
0 answers
52 views

Adding more fields to a Questionnaire in a CRUD system

Background on Project When a customer orders a machine, I have to do something called a telephone site survey, which involves asking them questions about their site making sure everything is okay ...
Jack Lythgoe's user avatar
0 votes
0 answers
51 views

Create trigger that updates Table3 from an insert into Table1 that multiplied by a value in Table 2 in MySQL

I know this is probably more complicated than it needs to be, however, I would really appreciate some help. I'm trying to create a trigger in MySQL that will update the value in the Costs table when a ...
Ramen Enthusiast's user avatar
2 votes
1 answer
74 views

Calculate of the average of time discounted values

Given the current table: ...
Jossy's user avatar
  • 133
4 votes
0 answers
2k views

Student report card management Python program

The program is designed to take data from a MySQL database, using mysql-connector-python, and print it as a table in Python using the texttable module. The program also plots charts based on the data ...
Random Person's user avatar
0 votes
2 answers
2k views

PHP search multiple filter inputs

Okay so I built this search page that searches for posts but my current code seems so bloated and inefficient. My script(search page) ...
JÂK_JÂP_JÓ's user avatar
8 votes
3 answers
747 views

Schema design for user profile and transaction

I'm creating a schema design for a user profile and transactions. I am very new in data modeling and currently this is my design. The schema has multiple deposit ...
9years's user avatar
  • 81
7 votes
2 answers
199 views

Connect to MYSQL database in PHP with prepared statements

I have recently learned about using PDO. I created a db class which could handle common actions like create, update, delete and select. Is this method a correct way to connect to the database using ...
Sanidhya's user avatar

1
2 3 4 5
23