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

learn more… | top users | synonyms

0
votes
0answers
10 views

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

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
45 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
21 views

Resort $_POST array [on hold]

I use this form: ...
0
votes
0answers
17 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
29 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 [on hold]

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
42 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
23 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
31 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
16 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
0answers
14 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
20 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
78 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
30 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
36 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
38 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
26 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
24 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
51 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
35 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
61 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
33 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
14 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
57 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
29 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
72 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
21 views

Write to terminal and buffer

...
0
votes
1answer
54 views

JSON Writer (PHP)

I have written a simple PHP Script that takes $_POST input and uses it to add data to a .json file. Given the security flaws in ...
5
votes
2answers
55 views

Steam Community Market Strange Part Scraper

A while back I wrote a simple little PHP script that searches the Steam community market for any TF2 strange weapons with strange parts on the first page of results for that weapon type. It works by ...
3
votes
3answers
157 views

Building prefix tree from dictionary, performance issues

I'm trying to build a prfix tree. So, using the following dictionary 'and','anna','ape','apple', graph should look like this: I've tried 2 approaches: using ...
-1
votes
2answers
38 views

Find multiple keyphrases from a text

I have keyphrases abc, xyz, pqr, mno, etc. Text - " this text contains abc and mno", want to find whether text contains keyphrase string. I am looking for an efficient solution. ...
0
votes
1answer
71 views

PHP pages that interact with MySQL

Could someone review this PHP code to see if my pages are coded safely to not allow common attacks (SQL injection, XSS, etc.)? I would be thankful, of course, for anyone to point out other problems in ...
0
votes
2answers
36 views

Array that defines product information and generates the html for the product

Is there a more productive way to do this? Is my code up to standards or up to best practices? ...
2
votes
2answers
41 views

Re-sorting newsfeed based on date

Background: A client side I made recently has a component that is made from several (20+) rss-feeds, and the feeds are mashed into one using FreshRSS hosted on our servers. For some reason, FreshRSS ...
1
vote
2answers
58 views

Select random row using PDO

What do you think of this way to generate a random number from the total rows in a table? I would like to create a page that random.php precisely generates a random ID and shows it. ...
2
votes
1answer
45 views

Import data module

I have a custom module to import nodes from a .txt file. (Drupal 7). My problem is I have a lot of nodes to import and this function takes so much time. ...