PDO is a PHP extension that serves as a data access abstraction layer for accessing databases.

learn more… | top users | synonyms

8
votes
1answer
64 views

Multiple MySQL select statements

I'm making a web application for a restaurant kind of type. The idea is to administrate the orders and customers. For selecting one of the orders and showing more specific data about it, i've got ...
5
votes
1answer
55 views

PDO Login/Register system I've been working on

I'm relatively new to PHP and programming as whole. I'm sure my code could be better in a lot of ways, most of which I can't fully grasp at the moment. As it stands I'm trying to avoid the general ...
4
votes
2answers
69 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 ...
2
votes
1answer
54 views

Using fewer foreach loops to bind values to parameters in PDO

I want to make a query to order by the IN clause items. I read from another thread that I can use ...
4
votes
1answer
39 views

Admin section - Secure login and authentication

After a lot of back and forth on various sites, reading articles, watching videos etc i still can not figure out the best way to secure my admin section. The ...
5
votes
1answer
61 views

Secure way to store passwords

Here I'm trying to develop a simple framework for my own purpose. I'm using PHP and PDO. But, I'm still worried about my password security codes. Below I have posted my codes. it stored like these in ...
4
votes
1answer
54 views

Random select in two MySQL tables

I wrote a simple AJAX request that performs a random select in two MySQL tables. The thing is, my current script involves connecting to the database and creating a new PDO every time the ...
2
votes
1answer
79 views

AJAX request authentication to PHP script

Recently I started looking at my AJAX call security and found some code that uses tokens, request and referer in an attempt to authenticate the call and stop XSS and CSRF. The AJAX calls are for the ...
4
votes
1answer
89 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 ...
3
votes
1answer
43 views

Login system, PDO and me - Part 2

This is a follow up question to: Login system, PDO and me Is this considered secure for a login script? ...
7
votes
1answer
107 views

Login system, PDO and me

I have run into a bit of a dilemma. Binding user input and building a prepared statement is all well and good, but what if I need the user input as a variable for a compare? Can I just create a ...
3
votes
1answer
126 views

My first login class in PHP with PDO and bcrypt

This is the first time using a class. Please review this and tell me if it's secure and if it's the right way to do it. The code itself is working, but I have doubts in the way I used all this. ...
1
vote
3answers
126 views

Security of code snippets

Last time I made a website using PHP, I didn't know of PDO, so someone dropped all my tables. I think I've made an improvement now. I'm sorry if there's a lot to go through, but I want to make sure ...
3
votes
2answers
91 views

POST security with PDO?

So I have some code that works as PDO. But is it secure? I'm trying to prevent SQL injection. This is my first PDO script and was hoping to see if it was done correctly. Here it is. ...
4
votes
2answers
96 views

Optimizing cron job for sending reminders

The following script is being run with a cron. It runs once a minute to see if there is a reminder that needs to be sent. Should I make this run once every 30 minutes? The choices to send a reminder ...
5
votes
1answer
45 views

Secure Functions in a Database Class

I am trying to solve as many issues as possible with my Database Class and bind statements as far as possible without actually doing it in the front-end. The goal is to do all of the heaving lifting ...
2
votes
2answers
121 views

Should a PDO object be passed to classes and procedural functions as a parameter?

I've been trying to figure out the best way to manage database connections for a while now and am still unsure of how I should be doing things. I know there are a lot of similar questions on here, but ...
0
votes
1answer
71 views

Is this the right way to write OOP PDO classes? [closed]

I have just begun to work with OOP and I am converting my current project into OOP classes. I have a few questions about this User class. ...
4
votes
1answer
62 views

Entire PDO DB Class

Last time I asked a question here, it was for my select function. In that question, another user stated the way I did it, might not have been safe. So here I am with the entire class. The class I'm ...
4
votes
1answer
117 views

My simple PDO wrapper class

I made a simple database class and I wanted to know if there are any improvements I could work on as far as readability, efficiency, methods and making it modular goes. Any other suggestions are also ...
0
votes
1answer
43 views

Add user star function triggering PHPmailer email optimisation

The function below simple allows a logged in user to "star" another user for convenience when trying to find the that user another time. At the moment the function works as it should, it inserts the ...
3
votes
1answer
94 views

Is coding to an interface with regards to PDO the right thing to do?

Am I on the right lines for connecting to my Database? If not could somebody help me improve it or point me in the right direction? Index.php: ...
1
vote
1answer
110 views

How safe is my MySQL query?

I am using PDO for the first time in my project. In my previous project someone suggested me to use PDO as my queries were wide open to inject. I am pasting a sample code of my project. Can you ...
4
votes
1answer
128 views

Image upload script for adding items to a database

I wrote my first simple image upload script that allows users to add items to a database along with pictures of said item. My script takes the images uploaded via a form, processes and resizes them ...
1
vote
1answer
50 views

Tag Cloud using 2 queries (one nested), and a foreach loop: Is there a better way?

I have a database that, among other things, stores publications and publication tags. There is a many-to-many relationship between publications and publication tags. Simply put, I query the database ...
3
votes
1answer
63 views

advantage of using __call method

I have wrote simple class that allowing database selection and inserts.Could you please tell me does this a right way to use __call method with any useful advantage of it ? ...
3
votes
2answers
78 views

Is this following Separation of Concerns and PHP OOP standards?

I've been working with PHP for a while now, but unfortunately haven't delved into the OO side of it until recently. I've been reading up on separation of concerns and OOP best practices, and I think ...
5
votes
2answers
112 views

Preventing SQL Injection in user registration routine

At the moment is my code secure for SQL injections and so forth? I still need to hash passwords and make sure fields are valid and so forth. ...
4
votes
1answer
52 views

Evaluation of insert method from within a class using PDO

I am learning PDO. I have a class - User... ...
10
votes
4answers
717 views

Is this function vulnerable to SQL injection?

I've this function to list products from database by category. I'm using prepared statements but wouldn't this make it pretty pointless to use them? ...
4
votes
1answer
78 views

Redunancy Issues in PHP Class

I've been studying PHP for a while now and decided to dive into OOP. Most of my code was a mess and I've begun to refactor much of the website to OOP; however, I'm having an issue with redundancy in ...
10
votes
2answers
214 views

Want to check if I am using PDO correctly

So today after few years of not programming in PHP I decided to go back, but to do so I needed to change all MySQL connections. So I want to check if I am using it good. Earlier I used to write ...
8
votes
1answer
263 views

PDO sign up function inserting data into multiple tables

This is a sign up function called on form submission. It firstly inserts key user data into the users table. If successful, secondary data is then inputted into ...
4
votes
1answer
255 views

PDO prepared statement - binding variable number of values

Please let me know if I have over/under explained my question :) HTML table row - the numerals from each id attribute, in this example "408" and "409", are the database tables primary ID numbers, one ...
1
vote
1answer
89 views

Is this way of passing a parameter relatively safe? [closed]

I'm still playing with how I want to build the parameter. However, in the end I still want to pass it to the prepare statement the same. Note: $this->dbh is ...
3
votes
1answer
96 views

Is this a complete PDO prepared class?

Is this class perfect for databases? All I want to know is what I should change to make it perfect. ...
2
votes
1answer
68 views

Are fetchAll() and for() good choices for my code?

I use the following code: fetchAll and for($mich=0;$mich<10;$mich++). Is this the best way? Is there a better way, either ...
3
votes
2answers
150 views

PDO MySQL spaghetti coding

I'm new to this PDO PHP and I have coded this spaghetti style. I hope you can give me idea how to improve using prepared statements. I'm not a lazy person, but I really need your help to improve my ...
-2
votes
1answer
128 views

pdo variable in select query [closed]

i try change mysql code to pdo and make this codes: ...
6
votes
2answers
253 views
7
votes
2answers
96 views

Specific PHP Data Access Class

As part of a fun project to help build my knowledge of PHP. I've written a Data Access Class here to bridge the site to the database. I know there are a lot of posts and articles out there explaining ...
4
votes
2answers
248 views

Handling access to database connection both inside and outside of classes

Is this an OK way to handle access to database connection both inside and outside of classes? I used to include a PHP file -- database.detl.php -- at the very top of my index.php file containing the ...
0
votes
1answer
31 views

Generating revision-table to accompany existing table

This morning, I wrote a quick-and-dirty table-revision generation script: (gist). It is intended to be run in the command line. Here's the entirety of it (149 lines): ...
2
votes
1answer
112 views

Image rate system

I'm developing a site, which has an image upload section, and members and like the image, but a member can like it only once. I have a table, named uploads which ...
5
votes
2answers
146 views

Do you see any flaws in these prepared statements to avoid SQL injection?

I have used this guide to implement prepared statements in order to avoid SQL Injection. I made some tests and no error was shown. However, I would like to ask you if you see any flaw in the code, so ...
4
votes
1answer
2k views

PDO Login/Register system review

I wrote my very first login/register PDO system today. I know there is still a lot of flaws, but I was wondering what tips and advice you have to help me improve this. I know that PDO is much more ...
0
votes
2answers
2k views

Dumping a MySQL database to a file using a PHP script

I know there are countless questions on SO, and several articles on the web regarding this subject, but after looking at all the options, I was moved to write my own code to address my own ...
2
votes
1answer
2k views

Converting entire table to JSON data. Is there a better way?

Building a 'card' database: I'm simply learning to take input data and store to database. Incorporating JSON, PDO, SQL, and enforcing my general coding skills through PHP, hopefully. ...
3
votes
1answer
1k views

Building a histogram array in PHP

I'm visualizing my stored data in an histogram similar to this one: However, I'm sure that my code smells a lot! So I'd like to have your opinion on how to make it better. ...
0
votes
2answers
438 views

Critique Requested on PHP Pagination Class

I did most of my PHP coding back with PHP 4, and among the projects I did was a popular pagination class. I've been meaning to bring it up to date with PHP 5 and OOP practices. I've also been working ...