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

learn more… | top users | synonyms

1
vote
0answers
13 views

Class method to insert a record into MySQL

I'm just starting out using OOP; classes and methods etc. I've been looking around for some PDO classes/wrappers out there, but there's not much to choose from. So I've tried to make my own. Started ...
1
vote
1answer
54 views

Populating an HTML combo box by looped concatenation

This code takes the results of a database query and uses them to populate the options in a combobox on a form. Would it be better to start with an empty htmlCode ...
1
vote
0answers
19 views

Local branch update script using Git and PHP

I'm using Git and PHP to create an update script which is sync local branch and the master. It checks about new updates, and if yes, it proceeds to the Git pull request and any response got from the ...
0
votes
0answers
15 views

twiiter max_id and since_id [on hold]

i am using twitter user_timeline api to get all tweets of a user . it returns 200 in single request but problem is that i want to get all tweets if tweets are like 400 or 500 below is my code that ...
2
votes
0answers
13 views

Limiting WP user's access to the amount of credits they have

I like this solution but maybe there is another way. My goal with this is to limit user editing to the amount of credits they have. What do you think? Here is what it does: Credits are stored as ...
1
vote
0answers
34 views

Prepared statement inside function that then return results

I've created a function that makes a query of a database table and managed to use the results in another page where the function is called. Is this approach good? ...
2
votes
2answers
74 views

Parsing a config file

I was asked to write PHP code that can be used to parse a config file on the same server (same directory as well) and output all configuration parameters, and have them all be cast to the correct ...
3
votes
1answer
28 views

Tag manipulation using DOMDocument

On our main symfony2 application at work I have had to manipulate some outputted grid fields by wrapping them in a hyperlink tag. This happens in quite a few different controllers, so I made a method ...
1
vote
0answers
43 views

Permission control on Codeigniter

The User Model ...
1
vote
2answers
68 views

Show first n elements of array, and count elements not shown

This code mimics the "likes" tooltip from Facebook. Given an array with the list of users that liked the content, it shows the first n users and displays a final item with the count of the users not ...
2
votes
2answers
70 views

Timestamp when file last modified in C#

I have the following code in PHP that appends a file path with a timestamp of when it was last modified: ...
-4
votes
0answers
36 views

How to run php script in background using php? [closed]

This is my first file <?php echo "haiiiii"; $result=shell_exec('php hello.php &'); echo $result; ?> This is my second file hello.php ...
3
votes
2answers
82 views

Email Template Parser PHP Class

This is a very basic PHP class that I am working on which will allow me to provide an HTML template in the form of a string saved to a variable or into an actual template file. I can then pass into ...
2
votes
1answer
45 views

PHP include page index.php?page=GET safety preg_replace

I found a lot of working codes to include page in page on Internet but I could not find a safe code. So I decided to create one myself. The pages will be only stored in folder /pages/ and whitelist ...
4
votes
2answers
73 views

PHP echo GET to change a CSS theme file

I have the follow code to change between different CSS theme files, I would like some reviews on it because I am sure it can be improved to be safer. ...
-2
votes
0answers
16 views

Code apear on the page [closed]

Hello i have made a php page and it was working and then the codes started to apear at the page like this ...
1
vote
0answers
29 views

Image upload handling in Laravel

I'm trying to create a handler to set the profile picture for the user. Don't worry about the validation as I will clean that up, because that's for testing purposes. This is how far I went. I'm using ...
0
votes
0answers
26 views

User Management OOP [closed]

I'm trying to figure out how to properly work this out. I don't know if I'm applying things correctly. I think it's a good thing to separate the User object, from the database operations, meaning that ...
1
vote
1answer
35 views

Filename interpreter for TV shows

I have small class which interprets TV show filenames to extract the show title and episode number. Due to the nature of the filenames, I have chosen for a cleaning approach: I clean the filename ...
1
vote
1answer
34 views

PHP PDO Database Wrapper

I'm trying to wrap my head around OOP, and am fairly new to PHP in general, so please forgive me if the following makes you cringe. I've decided to try and create a basic database wrapper using PDO. ...
3
votes
1answer
43 views

Form builder class

I am trying to learn OOP in PHP. My PHP knowledge is pretty good, but haven't tried OOP before. I'm currently building a formbuilder class. Can you take a look and tell me if this is the right way? ...
-1
votes
1answer
23 views

Human Readable filesizes

I am re-inventing the wheel and would like to lay down a comprehensive filesizes function. The only issue is that I guess bit-wise operators are more efficient but I'll be darned if I can understand ...
1
vote
1answer
23 views

PHP form to database fit for purpose

This code is intended to take input from a form and append it to a database table. The same data is sent to a separate function for subsequent mailing to the respondent. I'm self-taught and it works ...
3
votes
2answers
46 views

Getting a local file with file_get_contents

my url is like page.php?path=content/x/y/z/aaa.md. Is the following php code secure? ...
3
votes
1answer
44 views

Matchmaking system - sorting musicians by skills, genres, and location

I'm making a matchmaking system using PHP and MySQL which allows users to search through a list of musicians so that they can find people with the right skills and interests who are near them. It ...
1
vote
0answers
25 views

Decoupling payment classes

I have several classes for payment handling, I separate these classes into directories like below. Actually I'm going to use it for Laravel project but to make it simple, maybe we can talk as if it's ...
5
votes
1answer
54 views

Login Authentication

Please check this PHP script. This script is for Login authentication Some pre-defined constants to indicate the login state ...
2
votes
2answers
41 views

PHP function (in WordPress) echoing HTML

I'm really new to PHP, and a little less so in WordPress. I've created a working function that spits out some static HTML into a page template in WordPress. I'd like to know if there is a best ...
3
votes
1answer
49 views

Choosing a color based on exam score

How can I simplify this code? ...
1
vote
1answer
52 views

Serializing user data to send to another API

I'm trying to improve my OOP skills in PHP. One of my projects requires me to get user info from one API and send it to another API with a different structure. I will use a simplified situation, but ...
1
vote
1answer
42 views

PHP PDO / MySQL helper/wrapper functions

Further to my previous post for a user login script I've been learning PDO in order to migrate from mysql_* functions. As before with mysql_*, I wanted to wrap the PDO code into wrapper functions, so ...
1
vote
0answers
30 views

Time table for users

I'm working on a WordPress theme and creating a time table which will be easy to complete by users. In the back-office, there are a checkbox for each days: ...
-2
votes
0answers
27 views

What is more efficient in constructing PHP classes? [migrated]

For each of a bunch of records from my database I instantiate a class. Inside that class I call another class. Example ...
-1
votes
2answers
32 views

MySQL query in nested loop to get scores and averages for students

I am trying to get the scores and average for all assignments for records in a MYSQL database. The code below works but seems to take quite a bit of time to run because of the nested while loop. Any ...
5
votes
3answers
86 views

My lost password function

I'm trying to create a lost password function on my site. When a user enter their email it updates 2 columns in the users table with that email called: ...
2
votes
1answer
78 views

Get ranges from array of days

I have an array of dates as input in the form "YYYY-mm-dd"=>category_id.0 (category_id counting from 0). ...
1
vote
1answer
24 views

Multiple Wordpress metaboxes in fewer different functions

Is it possible to call multiple metaboxes in Wordpress with less duplicate functions? For instance, these are my current metaboxes (3 of them, one is a checkbox and two others are text input fields): ...
2
votes
1answer
89 views

Database Access Object Class

I learned of the Database Access Object design pattern from a friend and decided to implement it recently to my MySQL database. The code uses MySQLi to connect to the Database, and uses prepared ...
2
votes
1answer
159 views

PHP user account login with salt

I'm creating a user account login with PHP and Mysql which will be used by school teachers. To login there are 3 items required : school, username and password. This will allow for 2 of "MRSMITH" in ...
0
votes
1answer
76 views

Combine Mysql limit query

Is it possible to combine these queries into one query? I am trying to see and average all scores but also count and average just the last three based on the same grouping. This is the main query: ...
3
votes
1answer
17 views

Virtual Airline Dispatch Generator

This Code is old and I am trying to figure out how to improve it. I am considering running the distance function in MySQL, but it is a ***** to figure out for me due to my experience with arithmetic ...
3
votes
1answer
53 views

Quick sort in PHP

Does this code show proper implementation of quick sort algorithm? If not, why? Can this code further be improved? ...
3
votes
2answers
79 views

PHP contact form

I recently had my site hacked, with the main index file being overwritten (nothing else was touched). I'm assuming they hijacked my form input. Are there any vulnerabilities in the code or does this ...
5
votes
1answer
57 views

Script to upload CV with cookie control

I have created a script which presents a popup on every 5th pageview. I would like to try to use just PHP cookies. However, due to the requirement of setting them before any content is output, it ...
1
vote
1answer
41 views

Interface injection and common functionality between classes

I'm trying to get my head around the OOP principles and coding my own classes. As a means to learn, I have decided to convert a couple of functions I have written in Wordpress to OOP classes. These ...
1
vote
0answers
36 views

Do I need to separate controllers by HTTP request? [closed]

I am in the process of learning proper mvc implementation. I have decided to work on a small project in my spare time and I am stuck on the controllers. I created a basic router that matches URI using ...
1
vote
2answers
52 views

Bubble sort in PHP

Does this code show proper implementation of bubble sort algorithm? If not, why? Can this code further be improved? ...
2
votes
1answer
34 views

Reading and Converting XML File to Array

I'm using WordPress ( PHP Based Platform ) and I'm trying to read an external XML File, convert it into a usable array, then compare two arrays - one from the xml file and another from an options ...
2
votes
0answers
32 views

Custom backend app with require.js approach

I'm working on a small custom backend app in PHP for personal use (and practice MVC) and I thought it was a nice opportunity to try (and learn) requirejs to 'organize' my scripts and load just what ...
3
votes
3answers
100 views

PDO class and security

I have started a project in PHP with PDO and I'm almost done, but I've read somewhere that PDO escape alone is not secure and we have to consider some settings of PDP. I am a little confused about my ...