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

learn more… | top users | synonyms

-2
votes
2answers
56 views

Using a lot of IF in loop WHILE to print information

I made a code and it is doing what I want. But, I would like to know if I am doing it right or in the best way. Could you please give me your thoughts about it? Thank you. ...
0
votes
1answer
17 views

Indexing columns to make a MYSQL query faster

I have this query here that I am trying to make more efficient as it is taking an extremely long amount of time, about 40s on 3 million records. The query basically takes X amount of rows per company ...
1
vote
0answers
29 views

Archiving an SQL table of sessions and statistics

What my query is doing: I have two SQL tables and I want to copy datarows from the one table to the other table. I am doing this for statistics. The source table includes all current ...
2
votes
2answers
41 views

Registering usernames and passwords to a database

Here is my script that registers a user to a database. I am still very much a newbie when it comes to this topic so any guidance would be greatly appreciated. ...
0
votes
0answers
8 views

Implementing versioning system with MySQL [migrated]

I know this has been asked here and here, but I have the same idea with a different possible implementation and I need some help. Initially I had my blogstories ...
0
votes
1answer
43 views

Update live table in MySQL

After populating the stock_tmp table, i'm running these SQL queries via legacy mysqli wrapper code. I don't think this code ...
-5
votes
0answers
24 views

Bad filename in the address bar when require in a form action's file [closed]

I have a form: <form method="post" action="do.php"> ... </form> In do.php I require an another php file: ...
1
vote
1answer
25 views

Selecting mail messages that meet one of four search criteria

This is the current very repetitive and long SQL I have. Unfortunately I'm not that good at SQL to group this and get rid of the repetition. ...
3
votes
3answers
56 views

Grabbing hashed password from a database

I have just discovered the beauty of prepared statements in PHP and how they protect against SQL injection. In my first time using them, I am attempting to grab a hashed password from a database and ...
0
votes
1answer
67 views

MySQL JOIN to JSON array

I'm building a HTTP API and this part should return a JSON list of posts and their attached photos, like this: ...
5
votes
2answers
36 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
2answers
76 views

Password recovery program

This is a password recovery program I made, and I just want it checked out. These aren't all the files for the login and register system, only the password recovery part. The columns in the ...
3
votes
0answers
38 views

GUI SQL interface for select insert and remove

This is my final project for my second Java class! I would like to get some feedback on it to see where and what I can improve. There are five class files: guimusic/main this contains all all of ...
1
vote
1answer
72 views

DatabaseManager and connection in C#

I am posting here to get a code review on my DatabaseManager and DatabaseConnection classes, and for answers on how I can improve. I won't spend too long drolling on, but this is a database manager ...
6
votes
1answer
129 views

mysql_safe_query()

I have been thinking of a sql-injection free implementation in dynamic languages. Here's what I came with. All the code was written just for fun and learning purposes. I would like to share it and ...
5
votes
1answer
43 views

Impyla parse user args into SQL query

My Python is super-rusty and I feel like there must be a better way to do the following. I would really appreciate any feedback/pointers so that I can improve my code and skills (or lack thereof!). ...
3
votes
1answer
157 views

PHP class architecture and dependency injection

Let me start off by saying I am not new to PHP or PDO, but very new to OO PHP, and have been struggling to get a firm idea of best practices in my head regarding dependency injection and structuring ...
1
vote
0answers
15 views

Server framework

I decided to abstract out some of the code I use in personal projects into a library. In particular, it'd be used primarily for server-side programs, but I don't see any reason it wouldn't work fine ...
-1
votes
1answer
53 views

MySQL security in PHP

I'm creating a database class. It's part academic and part something I may show in an interview. The purpose of this method is to accept a table name as a parameter, check if the PDO Object has been ...
2
votes
1answer
66 views

Retrieving result sets from a MySQL table

This retrieves result sets from a MySQL table. The objective of this function is to correctly retrieve any number of rows (with $sql) from a MySQL table, binding ...
1
vote
0answers
18 views

Find nearest location

I am trying to implement a "find nearest location" from a given latitude and longitude using MySql. I have 8000 locations stored in my WordPress website. I managed to write this: ...
4
votes
1answer
75 views

Hotel reservation system with discounts and deposits

I'm making a hotel reservation app that has the following features: Promo Codes: The guest can choose to pay half a certain percent of the total_amount or the ...
1
vote
0answers
86 views

Login authentication model

I have made my model global so that I can work only a model with several controllers. Is it good or bad practice? And according to this, is my login process secure? Login check function in ...
2
votes
1answer
52 views

Function to streamline PDO statements

This function arguably has little use as it's so simple, but I'm writing a web application with a lot of SQL statements littered all over the place and I thought this function might reduce code ...
5
votes
2answers
53 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/...
3
votes
1answer
74 views

sed-like attempt from database

The following code and test data works, but I have had to add delays between writes to MySQL otherwise it acts funny (especially on the target data set which is over 700 rows). The table is simply a ...
5
votes
1answer
132 views

Website user password verification

I have a login web page where a user enters their email and password and I need to check if: the entered email exists in the DB and the entered password matches the hashed one from the db. The ...
1
vote
1answer
36 views

Query containing array

I want to get the query result that contains all entries from array and some data from the DB. It's like the array is a DB table and by left join I connect the data ...
3
votes
0answers
29 views

Database syncing playback of videos

I made a website last night that allows people to sync HTML5 <video>s (playing/pausing). The way it does this is by using Ajax to run a MySQL query every 2 ...
3
votes
1answer
150 views

Query SteamIDs for presence of an avatar

I have a table vanrust_corev2.tblPlayerLog that has approx 6.7k records, I also have a table in a different database ...
7
votes
1answer
111 views

OR vs UNION in message tables

I have a dilemma. I have a messages table containing fields id, sender, receiver, body I need to select all users a given user has had a conversation with. A ...
2
votes
1answer
31 views

Using view for repeated subquery on a large table

I have a large table with which I need to do some analysis. The table is a log of IPs: ...
2
votes
1answer
38 views

Restaurant booking subquery

I have two database table name called "tablestr table" and "restbookingtable": tablestr: restbooking: I want to retrieve bookingsection_id from the booking ...
2
votes
2answers
60 views

Storing customers' orders

I'm developing a shop system and using this method to store the customers with their respective orders: ...
1
vote
1answer
52 views

Medical database design and queries optimization

I have created a MySQL database which will be used in a medical app, but I am pretty sure the design and the used queries can be improved, since I am new in database design. My biggest doubt is the ...
7
votes
4answers
453 views

Preventing duplicate numbers from being entered

I recently wrote a program involving a MySQL database using C#. The program is simple: it allows users to enter numbers and ensures that no same number is entered twice. Now I know that it is not ...
2
votes
0answers
51 views

Processing database data into a multidimensional array

The purpose of this code is to get data from the database and output it into a multidimensional array in JSON for my web app. But my gut instinct is telling me this code is way too messy and just ...
-1
votes
1answer
49 views

optimize mysql taking too long

Today I made a clumsy update without WHERE. Yeah, I know. I have backups but I found a way to fix it without loosing anything. It implies a ...
4
votes
1answer
85 views

Selecting and inserting MySQL records using PDO

This PHP class connects to and queries the database MuSKL. I am a novice, and I ask you to comment on the approach and style of code. ...
4
votes
3answers
61 views

Database select script

Is there any way I could improve this script, such as by writing it in fewer lines (more efficient)? I'm very interested in keeping my code dry and fast! Also, if there is a way to make it more ...
4
votes
3answers
308 views

Preparing and executing MySQL SELECT query from parameters

I am trying to make a function for Select statements. It will give result based from the parameters passed. I tried using it and it gives the results I am expecting. I know that it is still ...
7
votes
2answers
746 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 ...
5
votes
1answer
83 views

MySQLi library for handling MySQLi interactions

I wrote this class recently to better structure and handle MySQLi related interactions with PHP and would love to get some feedback. ...
-1
votes
1answer
36 views

Listing blog post excerpts

I have created many sites that requires php and html. They all work fine, but I'm now thinking if all that time I do it in a wrong way. Usually, first I build the site template, then styling and last ...
7
votes
1answer
52 views

SELECTing percentage and count of votes

I have the following tables structures: ...
1
vote
1answer
38 views

Performance of summing one value from join of three tables

I have a table I want to get a sum of information on, but the value I need to query on is in two different tables. The one with values I need to sum is say, kudos, which has a value indicating +1 ...
2
votes
1answer
45 views

Placing navigation items into an array

I am looking for better ways to write this code. At the moment it grabs a list of all navigation items and places them into an array (using PDO). However, as you can see, it is using two ...
4
votes
1answer
23 views

Youtube OAuth security

I am working with Youtube OAuth for the first time and I am not that great when it comes to security. I got the following code and would like to hear if you guys can find any security issue: ...
1
vote
1answer
44 views

Laravel time-punching database structure

I am trying to build a database structure for a time punching system. What I'm trying to figure out is if what I have is the ideal structure, or if something else exists that I'm overlooking. I want ...
2
votes
2answers
89 views

Performance of MySQL helper class for VB.NET

I have inherited this code from my company. It is acting as a helper class for a database and written in VB.NET until date. It is working properly and almost 5 to 10 commercial packages I am ...