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
1
vote
2answers
259 views

Creating SQL queries for a MySQL database

I am writing a PHP application that works with a MySQL database. As I am fairly new to PHP I am looking for ways to improve my code. Below are two functions, ...
3
votes
2answers
969 views

Inserting an entire form into MySQL database

Please review this. ...
2
votes
1answer
114 views

Wordpress $wpdb->row Query Check

Looking at $wpdb class, I found get_row, and I am unsure if the function automatically prepares the query. I believe it does not ...
6
votes
2answers
4k views

PDO wrapper class

...
6
votes
2answers
17k views

Read from SQL database table, store in list of objects

...
0
votes
1answer
10k views

How can I display the results of mysql_fetch_assoc in a dynamic table?

I have a MySQL database with several columns and two rows of data, so far. I'm using mysql_fetch_assoc to return the data in database, but I don't know how to put it all together in a table so that I ...
1
vote
3answers
358 views

How could I make this PHP $_POST more secure? -Or is it secure already?

On most my $_post data inputted on my site I use the following php: ...
2
votes
2answers
1k views

Function to store data in MySQL database (using OurSQL)

I am parsing a huge XML file. It contains some million article entries like this one: ...
2
votes
1answer
218 views

Query of top players of the month

In a web game there is a ranking of the top points games played of the month: ...
1
vote
1answer
165 views

PHP email selector class

I've only been writing php for a couple of months, and I've never really had anyone to look at any code I have written. I've written this class, that returns an email address from a database, based ...
2
votes
1answer
4k views

Login and signup validation php critique

Please critique my login and signup validation php files.. login.php; ...
1
vote
1answer
1k views

Cash Register database structure

I would like your thoughts on my database structure. I am kind of a rookie but I am trying. All of your suggestions, alternatives, ideas, additions are welcome. Thank you. ...
3
votes
2answers
407 views

PHP simple engine

i have created simple php engine, i want that this engine used html/php codes from mysql. Here is this php code and please if you find out some mistakes or bugs, please post here. I realy want to use ...
2
votes
2answers
220 views

Sanitisation function: any holes?

I've come up with this small function to make user submitted strings safe for MySQL. I'd be grateful if someone could point out any security holes in this. I've tested it out, and it happily replaces ...
2
votes
1answer
874 views

Polling script to determine the continuous time a user has been connected

I've been asked to keep track of how long a user has been connected to a site without interruption. So far the solution I've come up with is to use ajax to poll the site every now and then to check ...
6
votes
2answers
818 views

Querying MySQL from an external application

I have a database that I need to query over and over as fast as possible. My queries execute pretty quickly, but there seems to be some additional lag. I have a feeling that this lag is due to the ...
2
votes
1answer
469 views

MySQLi_STMT wrapper, allows placeholders

I've made a simple wrapper for MySQLi_STMT, allowing the usage of placeholders and spares you the need to manually bind variables. The full code is at the bottom of ...
3
votes
1answer
209 views

Maintaining a column for each datatype

I have a function that is suppose to store variables based on their datatype, and this is table I have come up with to store those variables into. Is it smarter to have everything broken down like ...
4
votes
2answers
2k views

How can I improve this PHP MySql Rank generation function?

How can I improve this PHP MySql Rank generation function? (Mostly looking to improve speed, but any feedback is very welcome) Right now I keep stats and ranks in 2 separate tables. The only ...
6
votes
2answers
427 views

Working with databases in PHP

I am 100% self-taught, and so I try to read as much as I can about best practices, conventions, etc. However I freelance, and have been in a long-term contract position for the past little while with ...
3
votes
3answers
547 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
516 views

Session in database

I'm posting my PHP code for sessions using MySQL. Please tell me if there are any errors, if it can be optimized, or if security can be enhanced. Host: localhost User: root Password: "" Database: pro ...
6
votes
1answer
447 views

Retrieving the most recent communication from a user

Could someone review an accepted answered I gave on Stack Overflow? The use-case is as follows: Given a messaging system where a user can receive a message from a single user and send messages ...
4
votes
1answer
728 views

Implementing PDO, code correct so far?

I have decided to go PDO and have started implementing it on one of my webprojects. I have limited programing skills but can usually pull it off with some tutorials and forums. Here is my code this ...
5
votes
2answers
286 views

Simple activation script

The script is fully working, but I ask is there a better way I can do this rather than name all of the query variables, $q, $q1 ...
2
votes
3answers
510 views

Extracting and mangling a parameter from a MySQL configuration file

Is there a better way of doing this? ...
5
votes
1answer
869 views

Perl DBI Sample with MySQL DDL

I've been experimenting with Perl and MySql and wrote this code for connecting and writing to a database: ...
3
votes
1answer
246 views

Function from WordPress VoteItUp function [closed]

This code comes from a Wordpress plugin's forum called Vote it Up. It sort posts by vote. A lotof people say that there is more code than is needed. So I was wondering if someone have any idea about ...
5
votes
2answers
316 views

Gathering data from database

The following code has one of the most confusing lines I've ever wrote. I can imagine ten other way to write it but I do not know which else could be any better. Note: ...
3
votes
2answers
368 views

Database design for an online learning application

It is an online learning application with different types of learnable items, that different users learn. The users learn by spaced repetition (once right, wait a couple days, ask again), success is ...
7
votes
5answers
735 views

Securely handling a password protected application

I have some small applications that I want to secure. I've been using the following setup that I think is fairly safe, but I've never been able to set my mind at ease that it really is. Could you ...
8
votes
2answers
689 views

Object Paradigm for PHP, Practice in Design

I've created and I manage a point of sale web application built in PHP which has thus far followed no clear guidelines or methodology for development; it's operation is completely procedural. In turn, ...
7
votes
1answer
817 views

Avoiding sub-queries in named scopes

I use named scopes all over the place. When I have a named scope that deals with two different tables, I tend to query the second table in a sub-query. That way, if I mix and match with other tables ...
5
votes
1answer
589 views

Generalized PHP function for editing data in a table

I've got some legacy code which I need to maintain and its got this function which works perfectly fine, but I'm trying to understand if it is working using acceptable coding practices or not... I am ...
8
votes
5answers
12k views

Database class using PDO

The point of this question I'm actually using it while developing a simple application and it seems to cover all my needs. Also it uses PDO so that we don't really have to worry about SQL Injection. ...
8
votes
2answers
5k views

Connecting to a database

I'm working on a web application that I inherited from a colleague long gone. To connect to the MySQL database I use the following classes: statement.php ...
8
votes
1answer
434 views

Database method to query

I have a database class that in __construct() initialize a PDO connection and insert the instance into a $db private var. Now i'm working on a method that can be ...
18
votes
2answers
581 views

A take on DB Abstraction - PHP / MySql

It's a little bit more code but i wanted to show the full class. I highlight the points i'd like input after the source. I've cut comments since they where not in english and translated the important ...
6
votes
2answers
805 views

PHP/Doctrine bootstrap for review

Here's my bootstrap.php for my PHP/MySQL/Doctrine app. It's my first PHP app so I'm interested in learning from the experience of others how this could be improved ...
8
votes
2answers
1k views

Comparing data in 2 tables on different servers with CHECKSUM

So I've had a problem where I need to compare data in 2 different tables on two different servers. Now, I know MySQL supports CHECKSUM TABLES, but from my testing ...
27
votes
3answers
35k views

CodeIgniter Active Record Subqueries

I use CodeIgniter at work, and one of our model files had a lot of subqueries in it. I originally had to manually write each subquery, and wondered if I could use active records instead. So, to make ...
38
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 ...