Tagged Questions
3
votes
1answer
49 views
Refactoring of this complex PHP method
I have one complex method with 1890 paths. I don't know how can be this refactored. Can somebody add some tips about it? Maybe the MySQL table structure is wrong.
...
4
votes
4answers
451 views
Two while for the same query
If I have to loop results of a query echoing first all fields of a column, then echoing something not to loop, then fields of another column.
So I'm using
...
2
votes
1answer
54 views
UserDAO with CRUD functionality for my UserRepository
This is my first attempt at creating a DAO.
I would like to get some feedback regarding the following aspects if possible:
Code readability
Efficiency
Usability
I also would appreciate any other ...
0
votes
0answers
40 views
Update database, refresh the page to show changes, show a success message
Follow up question for:
Update database, reload page then show a success message
I have a table of articles, in each row is a button to activate / deactivate the ...
2
votes
0answers
33 views
Dynamically load data into bootstrap accordion navigation bar
I have made a bootstrap accordion navigation bar that loads data dynamically from a database with PHP.
Here are the two tables that I use:
...
5
votes
1answer
50 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
...
0
votes
1answer
72 views
Did you like my product?
I have the following MySQL query which selects product details and whether the viewing user likes them. I feel like it could be more efficient and that there is a more practical approach than using a ...
3
votes
1answer
54 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! ...
4
votes
1answer
200 views
Have I prepared this prepared statement well?
This is a prepared statement (I think). Have I done this well?
...
4
votes
2answers
61 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 ...
4
votes
2answers
149 views
Injections and query
I made a class that connects to my DB and inserts some values. Is it secure or how can I protect this further from injections? The object declaration will come from variables with POST from a form, ...
5
votes
2answers
66 views
Benchmarking our LAMP servers with this php script
I've written a small script to benchmark our LAMP hosted servers that assess the performance based on three factors:
Disk I/O
Database I/O (mysql)
Database I/O (sqlite)
The logic is as follows:
...
1
vote
1answer
66 views
A cart that uses SessionID
I wanted to create a cart that I can easily add some item or simply help someone at the other end over the phone. I decided to create a cart that would store everything on MySQL instead of using ...
0
votes
3answers
35 views
11
votes
3answers
216 views
Search script code efficiency
Is there a more efficient way to write this? This script will be used heavily and I want to make sure I do not have any memory leaks or speed issues.
This script gets an input from a form and ...
0
votes
1answer
25 views
Safely storing and output data
On my application I use this method to store and to output the data. I would like to know if it is safely and correct.
...
0
votes
1answer
29 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 ...
1
vote
1answer
100 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 ...
1
vote
1answer
33 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 ...
1
vote
1answer
50 views
Selecting three tables with relationship
I've been working on improving my website code. I've noticed that querying from a table inside a PHP while function, where ...
3
votes
1answer
59 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 ?
...
6
votes
1answer
122 views
Is this user login secure?
When it come to security I try to be to better as possible but I don't have the knowledge.
According to what I read on-line my following code should be good but I could use some of your ...
5
votes
2answers
94 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.
...
-1
votes
1answer
91 views
Is this shopping site safe from SQL injection attacks? [closed]
Please verify security from SQL injection attacks.
homepage.php
...
3
votes
3answers
80 views
Inline PHP IP access log
For a website, I've got some inline PHP, posted below. It's supposed to log traffic to the website, and it does its job fine. But at the end of the day, I'm not even close to a PHP developer, and ...
3
votes
2answers
86 views
Is there a “prettier” way of forming this query, or a more efficient way of joining the tables?
Yesterday I posted a question involving multiple nested queries. The queries pulled information from the database and created a directory listing of all employees. There are two many-to-many ...
0
votes
1answer
54 views
Would multiple joins boost performance, or are the nested queries an acceptable way to handle the situation?
I'm working on a directory that lists employee information. Each employee can belong to multiple departments and each employee can have multiple job titles. I have 5 ...
2
votes
1answer
195 views
How to prevent SQL injection PHP and MySQL?
I have been reading about SQL injection and I want to secure my code.
I am not asking anyone to write me a code, but I just want to learn it in simple terms. The best way for me to learn is to edit ...
4
votes
1answer
75 views
Am I organising my PHP code effectively?
I'm very new to learning PHP & MySQL (I've got past experience with Java) and I'm doubting whether my code is organised well. I've got an index page which has two forms; the first is a form to ...
10
votes
2answers
186 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 ...
4
votes
1answer
213 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
46 views
Replacement of MySQL Query [closed]
I want to replace an old MySQL statement with new one. Does anyone know me if the following replacement concept is correct?
The statement
...
5
votes
1answer
346 views
How is OOP achieved with configuration files in PHP?
Someone asked if their singleton is good for OOP:
Using a singleton class to get and set program wide settings.
However, the answer just provides tweaks to his existing code - but the question ...
3
votes
1answer
105 views
How to go from Spaghetti PHP OOP to SOLID OOP?
I am beyond stuck in a half way point between PHP structural and OOP, but I can never achieve proper SOLID patterns despite reading DI, IOC, and reading about the interfaces.
Rather than to read ...
6
votes
1answer
64 views
Removing image records if no physical file exists
I have a working script that selects image fields in all tables and empty their values if the physical file doesnt exist.
...
2
votes
2answers
135 views
6
votes
2answers
865 views
PHP login system - is it secure?
I have created a PHP login system based off of this site. My main concern is: Is it secure? I chose that because to me it looked secure, but a 2nd or 3rd opinion never hurts. The idea of the project ...
1
vote
1answer
86 views
1
vote
1answer
45 views
Like system with MySQL on multiple types of pages [closed]
I want to have a like system on my website on multiple pages like "news", "comments", "forum posts" etc. So I was wondering what was the best way to do it between:
having like tables for each of my ...
2
votes
1answer
79 views
Rendering a history list of shows with different options
I have some PHP code I'm working on which contains 2 queries and I need to set extra conditions for 2 out of 3 view options and one less query for 1 out of 3 view options.
Basically, I'm rendering a ...
1
vote
1answer
78 views
How to turn 201 queries into 1? [closed]
I have a PHP web app that manages contacts. It has four main functions that display: contacts with upcoming birthdays; the 20 most viewed contacts; all contacts (200 limit) plus their phone number ...
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
145 views
Listing with JSON or plain HTML
I have a website which has reviews about games. Right now, to list the advantages (+) and disadvantages (-) of that game, there's a textarea in the admin panel with a WYSIWYG editor with only ...
2
votes
1answer
187 views
How can I improve this PHP MySQL rank query?
In my db MySQL, I have a table ranks with many fields, one for each page I want limit access for the user in the menu application with PHP control:
...
5
votes
1answer
127 views
Best Practices concerning Includes and SQL Connect Strings
I'm just starting to learn PHP. I have three random questions about PHP and one question about Code Review. None of them are technical questions ("will this work?"); they're best practices questions ...
6
votes
2answers
218 views
5
votes
1answer
99 views
System for inputting and monitoring worker shifts
I've been building a system for inputting and monitoring shifts for casual staff, who work across multiple sites with the ability to generate accounting information.
I've had some help from Stack ...
3
votes
1answer
88 views
Query optimization PHP for string concatination
I have an entity RegistrationForm which has a OneToMany-relationship with SurveyAnswer.
An answer can either have a ...
3
votes
1answer
64 views
Searching for news articles in database
The first thing I would like to say is that I do have a fully functioning script, but the script is ugly, and I am wondering if there is a way to optimize it.
The script looks to see if I have at ...
2
votes
1answer
98 views
Update SQL query using UNIX time
I would like to test the following garbage collector code on a database of sessions.
It should be following the conditions below:
if 'remember me' is enabled by the user, then it should delete all ...