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
52
votes
2answers
58k views

Class for reducing development time

There are many PHP PDO classes out there, agreed. However I find they do not allow for flexibility. So I created one that helps reduce development time as little as it may be but it does the job (...
5
votes
1answer
9k views

PHP dynamic insert - mysql. Is there a better way than this?

I have a dynamic form that users can add extra fields too. The group of fields are added and the input name stays the same but gets a incremental number attached to it. So for my insert php file I ...
7
votes
2answers
4k views

Securing PHP shopping cart

I've managed to create a working shopping cart and my next concern is security, mostly about the architecture and session security. Should I make sessions somehow secure, if there's no authenticated ...
13
votes
3answers
7k views

Basic user registration code

My first attempt at a user registration code. Login.php defines database log in variables (e.g. Database name, Table name, etc) ...
39
votes
5answers
9k views

Database connection in constructor and destructor

I am playing with different ways to do database interaction in PHP, and one of the ideas I have been playing with is connecting to the DB in the constructor and disconnecting in the destructor. This ...
4
votes
1answer
2k views

Extendable PDO Wrapper Class

I've created a PDO wrapper. I understand PDO could be used on it's own, and I'm reinventing the wheel as there are solutions like Laravel's Eloquent that would do a better job. I'd like advice on ...
9
votes
2answers
4k views

MySQL class to add user/database

I'm creating tool to add new virtualhost on UNIX-box. One of tasks is to add a new user and database to MariaDB (aka MySQL) server. In fact - this my first 'real' attempt to use OOP. Here is class, ...
8
votes
2answers
142 views

Non-Entity framework database interaction model

A C# WPF user interface has been developed for the Book Inventory MySQL database previously shown in this question. Since the database had already been developed this was a database first ...
8
votes
2answers
273 views

Local user registration

More javascript (nodejs) to go with the passport wrapper I just posted: UserBook.js ...
9
votes
4answers
1k views

Inserting 1 line into my SQL database

This is for adding code into my table really easily, however it will be called 2000+ times per second, so I need to know if this is the most efficient code to add a row to the database. ...
5
votes
1answer
7k views

SQL database for a social network

I'm trying to create a mini social network mobile application kind of like Instagram and I'm not sure about my database organisation, it feels like something is missing, especially with the ...
13
votes
1answer
899 views

Abusing Excel VBA… to maintain data stored in a database

I need to build a little UI to allow easy maintenance of some data stored in a MySQL database, and the end user wants to do that in Excel (I know, I know). The code I came up with comes pretty close ...
10
votes
1answer
229 views

Science Fiction Wall of Fame (Shame?)

I have a few of hobbies, one is reading science fiction and fantasy and another is coding solutions. I thought I might have a chance to combine both hobbies on this project. I have well over 1500 ...
8
votes
6answers
24k views

OOP PDO Database Connection

I'm currently learning about PDO, and trying to connect to the database and CRUD in OOP way, this is a simple code that I use. index.php ...
14
votes
2answers
119 views

Revision 1 - Step 1: PsychoProductions management tool project

I started a project to build my own invoicing and management system to take the place of prohibitively expensive QuickBooks software. This will be broken down in 5 steps, with the current step in bold ...
11
votes
3answers
681 views

Secured registration script

I created code for my registration form on my social network. I want to know if it is secured enough to release on the web as a public social network. Also, all of the code works. I just want to make ...
9
votes
1answer
74 views

Step 1: PsychoProductions management tool project

I started a project to build my own invoicing and management system to take the place of prohibitively expensive QuickBooks software. This will be broken down in 5 steps, with the current step in bold ...
7
votes
4answers
356 views

Multiple SQL queries, one per ID

ids contains 100 ids that are comma delimited. Is it fine or does it need improvement? ...
6
votes
2answers
151 views

Complex query to count votes with a redistribution system - follow-up

I've previously posted a question about simplifying a query to count votes with a distribution system. One of the contributors, @200_success, pointed out that it calculated the surplus redistribution ...
5
votes
2answers
214 views

Volunteer Signup Report

I was creating a Volunteer Signup Report report in Microsoft Excel yesterday for my job and I had a moment of inspiration. What if I turned it into a website and made it dynamic? The volunteers sign ...
5
votes
1answer
116 views

Automatic database migration system

Github here: https://github.com/cmancone/mygrations I'm working on a different kind of database migration system for helping manage web applications. I asked a question about part of the system just ...
4
votes
2answers
693 views

Simple login system

I'm pretty new to PHP and programming general so I'm quite sure my code is an absolute mess. My goal is to write good code, that others can understand just by looking at it. This is a simple login ...
4
votes
1answer
129 views

Slow MySQL query - 1200 rows in 5secs

Can anyone help me speed up this query? At present, it returns 1200 rows in 5 secs. I've notice that it is looking at 240000 response records. I think this is where the issue may be. I've created ...
3
votes
2answers
186 views

Database Connection Program With HR Functionality

I've started writing a fully functional Database program in C# that allows a user to access a HR system (with more systems planned in the future). I have come over to C# from Java around two weeks ago,...
2
votes
1answer
3k views

MySQL vs PDO execution time

I'm having some issues understanding why PDO is 6X slower executing a query than the depreciated MySQL query function. Here's my code: ...
2
votes
0answers
54 views

Calculating effective shop inventories (SQL)

This is an SQL version of that question. Shops and groups The problem domain is a collection of shops (identified by an int shop_id number) each of which is ...
1
vote
2answers
226 views

Simple wrapper for PHP mysqli connection

I'm creating some web apis to sync some data between desktop/mobile apps. Working on it, I wrote a simple wrapper for mysqli connection to simplify querying like: <...
1
vote
1answer
170 views

Pages system PHP/SQL

I'm working on a CMS, currently on being able to create static pages, manage menus etc. so.. I have This function that reads from the DB and finds all the static pages, and their position in the menu. ...
25
votes
3answers
2k views

Complex query to count votes with a redistribution system

I've spent the last couple of evenings trying to build a system for redistribution of votes in a ranked voting system. I've finally come up with the model for redistributing surpluses from a candidate ...
15
votes
8answers
4k views

Asking a user to take money from a checking account and move it to a savings account

I'm aiming to get this program right as I might show it at a job interview. The code below runs fine but I would like to know if there's anything that can be improved in terms of readability, good ...
11
votes
3answers
785 views

Acquiring user information about students and classes

I have a Java application that uses a few switch statements to get user information about students and classes. I have three MySQL tables: students student_id | student_name | hometown ...
8
votes
4answers
575 views

Bad practices in this procedure to calculate player statistics?

I recently self-taught myself MySQL as quickly as possible because it was needed for a project that I'm working on. Now that I've got some time I've been working on improving some thrown together SQL ...
7
votes
2answers
574 views

Modifying `sakila` database

This is not "real life" code. I'm trying to expand upon the well known Sakila sample database for MySQL to make it more complex. Step 7 (or 6) is running ...
7
votes
2answers
3k views

Address book with database tables

This is my first time messing with PHP and I tried to put together a simple address book that when the user fills out the form it would update a database table, then display the row data on the page ...
5
votes
1answer
167 views

Conditional row count across 4 tables

I have the following function that works fine. Is there a better way to do it and will this be efficient if I have 100+ rows returned from each table? The database Tables ...
5
votes
2answers
74 views

Conditionals for time specific data (SQL style)

I was inspired by this question from @AndyRoid to try and come up with some fast and accurate datetime calculations that didn't involve complex if/...
5
votes
1answer
54 views

Separating Duplicates from Uniques

I have a MySQL table with a very large data. What I need is to find and separate duplicates from the unique rows Let's say this is my table: ...
5
votes
1answer
86 views

Resolving MySQL 1215 errors in a declarative MySQL migration system

Github here: https://github.com/cmancone/mygrations I'm building a migration system for MySQL that operates in a very different way than the usual. Rather than recording changes in the database, the ...
5
votes
1answer
438 views

MySQL IMDB Query Speed

I'm using data from a database from the IMDB website. The database consists of five relevant tables. Actor (id, fname, lname, gender) Movie (id, name, year, rank) Director (id, fname, lname) Cast (...
5
votes
1answer
96 views

Lastest version of my Blackjack game

This is the latest version of my Blackjack game that uses a MySQL database to store user info. I did everything I was recommended in my previous post, added a ranking system and also fixed a bug where ...
4
votes
1answer
982 views

Optimize MySQL double select inside for-loop

I want to get the number if items with state 4 and 1 from my database for each day between a certain date. Is there a smarter ...
3
votes
1answer
81 views

Blackjack game with database - follow-up

This is a follow-up to my ex-posted Blackjack game that uses a MySQL database to store the accounts and user's money. I tried splitting display_info() a bit, I also ...
3
votes
1answer
183 views

More efficient method to check for duplicate database entries?

I am saving company information in a database, and if repeat information is found, I want to update the overlapping rows. Some of the supported fields are emails, phone numbers, organization names, ...
3
votes
3answers
548 views

MySQL connection class

I am trying to learn OOP using PHP5 and I wrote a simple MySQL connection class. Please take a look and give me some feedback on better practices, critical errors, and any other feedback you can ...
3
votes
2answers
333 views

Asking a user to take money from a checking account and move it to a savings account - follow-up

I made a few changes to this: Asking a user to take money from a checking account and move it to a savings account The changes I made were: improved the names of methods and variables to better ...
3
votes
2answers
2k views

Watch a directory and insert new entries into database

This program's main function is to: Watch a directory. If there are new files, insert those as entries into the database. Delete the files from the directory. My below code runs well, but I want to ...
3
votes
2answers
447 views

Confirming safety of SQL injection

I believe with everyone's help on Stack Overflow, I got my code safe guarded from SQL injection. I'm trying to confirm that is correct, just in case I misinterpreted the help and advice I received. <...
3
votes
1answer
14k views

Update database, reload page then show a success message

I have spent a long time trying to find a way to do the following: Update a MySQL database with AJAX Reload the Page to show changes Show a success message I think I have finally found a way! Let ...
3
votes
2answers
181 views

Program for entering 1000 random numbers into two different databases, one for odd numbers and one for even

I have created a program in java for entering 1000 random numbers into two different database one for odd numbers and one for even. The code is executing fine but it takes nearly a minute to execute. ...
3
votes
3answers
229 views

Database of survey information

How does this look? It has been over a year since my database concepts class and I have never worked with MySQL. I have chosen InnoDB as my engine because of foreign key support using UTF-8 based on ...