PHP is a widely-used, general-purpose scripting language that is especially suited for web development.

learn more… | top users | synonyms

2
votes
1answer
28 views

Upload image with secure code

I have written [PHP code][ to upload image/s to server. (To see the result, open the JavaScript console of your browser, look at the Network tab or the Console tab.) The code is also available and ...
4
votes
0answers
43 views

My online hangman solver

I've created a simple hangman solver at solver.lukesalamone.com, and although I'd consider myself proficient in webdev I am by no means an expert. The trick with this is that since HTTP is stateless, ...
1
vote
0answers
17 views

PHP store data from form into MySql DB

This is the first time I've tried this. I'd like some feedback on how I did, including any bad practice warnings. For example is it a really bad idea to allow the code to recreate the table if it ...
0
votes
0answers
26 views

My take on implementing the Repository Design Pattern in PHP

The past few weeks I've been trying to grasp on nearly any Design Pattern ever invented, but the repository pattern is one I could understand and implement it myself in my project. My application uses ...
0
votes
0answers
4 views

Generate meta tags for paging on views, refactoring needed for 'if else'

I know this is a long code and hard to read but when i started working on this it was just a few if-s, and as time passed i added more and more and came to this. Tried refactoring it by my self and ...
-1
votes
0answers
11 views

Android API code block to upload image [on hold]

someone made me an API function to upload an image to a server through Android and I would like to know if it looks good enough or if it would work. ...
1
vote
0answers
40 views

Sorting a list by country name

A couple of weeks ago a company sent me this coding challenge: Please write a PHP web application and send it back to me as zip file: Which waits for a user action, like clicking buttons. ...
4
votes
2answers
178 views

Inserting a record into MySQL with a timestamp

I'm starting with PHP so I can save data to a MySQL database. I read a lot and it seems the "escape" strings is not so safe. This is my code: ...
0
votes
0answers
13 views

View/templating system with standard content and custom parents

I've been working on my own website, and decided to write an own framework for it. One of the items in the framework is a view/templating system, used to easily maintain presentation files (HTML, PHP) ...
0
votes
0answers
16 views

Sorting timestamp using the date not time (php, mysql) [closed]

I'm having a bit of a problem trying to solve this one, Currently i've got a php script that scrapes data from a MySQL db, on one part of it the DB has a timestamp which has date and time in it. ...
3
votes
2answers
55 views

Duplicates in array elements and sorting

I've been given this little test exercise for an interview as php developer, and I'd like to hear from you if my solution is good (enough) or if the problem could have been solved in a better way. ...
-1
votes
1answer
24 views

Resort $_POST array [closed]

I use this form: ...
0
votes
0answers
21 views

Php Ajax script to check server status of sites from db

I am writing a script for a client so hey can check the status of their servers. The script performs ajax requests to get the data as json then poulates the table with the returned json results. is ...
0
votes
0answers
33 views

PHP get a view object for a polymorphic model

I need to render polymorphic models in different situations. Model's base class: ...
-2
votes
0answers
31 views

Preventing Infinite Loops PHP [closed]

Let's say I'm building a simple ORM. The models this ORM works on can (and do) relate to each other in various ways. Most of these relations are pretty simple; however, it gets kind of tricky when ...
0
votes
2answers
46 views

Getting and posting data use PHP OOP and mysqli

I am not very experienced in php oop. Moreover, when mysqli comes with php oop, it make me more confused about using it in best efficient way. Anyway, first look at my connection class: ...
-2
votes
0answers
29 views

CRUD Operation Using OOP PHP and PDO [closed]

I am new to PHP and trying to learn OOP PHP. I am creating a registration form (a simple one) to learn OOP PHP, when I submit data the success message shows up but data is not inserted in data base. ...
3
votes
1answer
34 views

Get title from database based on member country

I asked this question before. However, I realized that I had to edit some of my code after I got good answers. Therefore, I'm asking a new question here. I have the following database: Each ...
0
votes
1answer
56 views

Load title from database based on member country

As tim suggested, some changes to the database was necessary. I have posed an improved version of this question at Get title from database based on member country. I have the following database: ...
0
votes
0answers
17 views

PHP dice game with classes [closed]

I'm trying to develop the 'roll the dice' with classes in PHP and with two dice and several players, do you know how the structure could be better? I've started with this simple code: ...
0
votes
1answer
37 views

Process bulk update actions

It's using four sections of code block, I just want it to be reduced to one contiguous set that does either a or b with the two sections not a copy/pasted approach as done here: ...
0
votes
0answers
21 views

Laravel transactions with a database

I'm really concerned about my transaction with a database and my code structure. I have created more methods to insert, update, delete data to the database but sometimes some of them will break or ...
1
vote
0answers
80 views

PHP MVC Architecture Implementation

as a learning project i have decided to try and implement/build my own take on a PHP MVC framework. I realise there are alot of good PHP frameworks out there but rather than learning how to use a ...
2
votes
2answers
62 views

Calculate daily average for selected period in PHP

I would like to calculate the average for the same days (e.g. Monday, Tuesday, etc) in a selected period: ...
0
votes
0answers
32 views

Simple ORM architecture

I'm practicing with some structural design and would like to know where this code can be improved. I can't imagine a structure where primary key is defined only once (now it passed in Table ...
3
votes
1answer
37 views

PDO update method

I am in my first object-oriented project and wrote this method for updating the database. The PDO include is just for convenience, so I could work on a single file temporarily. I'm not entirely clear ...
0
votes
0answers
23 views

Function fetching data from database

My DB function uses (ATTR_DEFAULT_FETCH_MODE) FETCH_OBJ to fetch the data from database. So for that reason, I prefer objects ...
1
vote
0answers
39 views

PHP login and session establishment

I would like to ask your advice on my simple code to login and registration sessions. In the User class, login function: ...
0
votes
0answers
27 views

Three functions to make a JSON array

Currently I'm using these three functions, that in the end produces a JSON array. I went this way so that I could fetch data from a specific table. But now it just seems bloated and poorly written, ...
2
votes
1answer
21 views

Printing the start and end dates of the most recent eight weeks

I have a table with columns dated by week that changes dynamically each day. Currently, I am using the following php code to get the proper dates for the past eight weeks: ...
2
votes
2answers
24 views

Insert into two tables during user registration using PHP

I'm working on creating a user registration script in PHP. I have two tables that need to be inserted into. One that stores some general user information, and another that stores their login ...
0
votes
0answers
25 views

Responsibilities in discount method on controller - Cart service

This method is accessed when the route cart/discount/hash_code_discount is fired. Basically, I have a cart in my session and by this method I need to recalculate ...
1
vote
0answers
52 views

A Search Engine Class

I've built a Search Engine class for a website that permits to search companies in base of their locations and their categories (companies pay a plan to be found in the places that they will). In the ...
0
votes
0answers
17 views

Performance of PDO-Query Class

to reduce repeating multi-liners I've written a class for my PDO-Querys. But as I used this in my project (a Webcrawler), I sometimes get the ...
2
votes
1answer
37 views

Form validation in core php with oops concept

Here, i build one form validation script in php using understanding SOLID concept. My question is the way i coded my code is true way for ...
1
vote
1answer
62 views

How to optimize Method Visibility and code structures for better performance?

I'm creating an application to get data cross domain all the line of code seem work as well but I'm not much understand about performance with my code process with the real server and real action ...
0
votes
1answer
25 views

class.FaviconFinder.php - add more validation

This is a second rev of this SE Question. How can I add more validation to this .ico file downloader? It works but I need a way to check the integrity of each step: Check Default location ( ...
1
vote
1answer
34 views

PHP function for encrypt / decrypt using openssl

This is a function that is the building block of one wordpress plugin. I came up with this code after some search but i need to optimize it and get any info from more experienced guys. ...
0
votes
0answers
15 views

Using OCI functions

I've never used Oracle with PHP before, what I'm doing is calling a stored procedure that returns a refcursor. Which is also a first. I use frameworks like Yii etc and don't seem to be able to use the ...
3
votes
0answers
42 views

Determine base URL of PHP app

I have this little piece of code which determines the base URL of PHP: ...
1
vote
0answers
26 views

Per-Module Unit Testing in ZF2 [migrated]

This question is about handling namespaces and unit testing in ZF2. Let's say I have a module called Application. I have constructed ...
0
votes
1answer
20 views

Converts Units of Volume; optimization and improvement

I am creating a volume converter. It allows users to enter a value and select the unit to convert from and the one it will be converted into. It uses a ...
-1
votes
1answer
58 views

Authorizing users for POST requests

I've to authorize some users to do POST requests from their CMSs in order to create a new resource on my database. I've to send a JSON response containing the status of the response (successful or ...
1
vote
1answer
48 views

Storing hierarchical data into a data structure

With the following data in a table, ...
1
vote
0answers
30 views

Algorithm and PHP Class to Compare companies' information and define similarity

The task is: I get companies' information from a large CSV file and then I need to compare this information with each company in the database to know if the company is a new one or if it is already in ...
2
votes
1answer
55 views

PHP Custom $_GET checker function performance

I'm trying to follow the DRY programming philosophy and I am tired of running isset() and an if not empty statements for each ...
1
vote
0answers
24 views

Save Custom Product Kit using Web Application

How far do I break down individual tasks within a typical scenario of "Web application reacts to user input"? For example, in the case below, say a scenario is "User submits a form, causing user data ...
3
votes
1answer
75 views

Basic MVC Framework

I want to improve my skills so i startet a very basic MVC framework. Its my first MVC based Framework. Index I rewrited all requests through index.php and the ...
1
vote
2answers
36 views

Sorting and slicing array, based on another “weight” array?

I have the following input array: ...
3
votes
0answers
22 views

Write to terminal and buffer

...