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

learn more… | top users | synonyms

3
votes
1answer
22 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
91 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
84 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
118 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
79 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
67 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
42 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
92 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
65 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
53 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
95 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
35 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
91 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
102 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
107 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
40 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
61 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
70 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
98 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
704 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? ...
3
votes
1answer
74 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
199 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
194 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
219 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
85 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
92 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
65 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
149 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
103 views

pdo variable in select query [closed]

i try change mysql code to pdo and make this codes: ...
6
votes
2answers
228 views
6
votes
2answers
92 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
189 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
104 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
138 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 ...
3
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
1k 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
415 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 ...
2
votes
1answer
148 views

User system using PDO

I'm making a very basic user system, and this is what I have so far: ...
2
votes
2answers
765 views

Saving and uploading images in a database

I am working on a small method that saves uploaded images and records the images in a database. ...
2
votes
3answers
226 views

Remove vulnerabilities from query on public website [closed]

I think that the following query is preventing against SQL injection, but what other measures do I need to take to ensure my queries are 100% safe from any malicious attacks? ...
2
votes
1answer
436 views

Optimize PHP and MySQL with PDO

I am updating some old reports that are using mysql_ statements and trying to use the MySQL PDO stuff. I was told that PDO is far better since I was running into ...
0
votes
1answer
101 views

How can I make this piece of code more secure?

I am using db_dataobject and have provided two examples of an insert and a select query below. Can you please help me rewrite them in a more secure way using PDO? ...
14
votes
1answer
15k views

Very simple PHP PDO class

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 ...
1
vote
3answers
421 views

Look over my code for PDO and MVC

I'm building this website with PDO and Pattern MVC. I'm currently working on the login page and would like to know if this structure is correct for MVC pattern. I'd also like your opinions and ...
2
votes
1answer
659 views

Structure pages mvc + oop

I am developing a website and I want to use PDO and MVC. Before, I was coding in procedural MySQL, but I'm starting to understand the object-oriented programming. My problem is the following: If I ...
4
votes
1answer
158 views

Is this code protected against SQL injection attacks?

I'm just wondering if this code is good against SQL injection attacks. I don't know how to check if is good. Also I would like to know if is good how I'm working or this is just bad practice? ...