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

learn more… | top users | synonyms

-1
votes
0answers
8 views

Correct form of passing $variable to mysql [on hold]

I am wondering which of the following two examples is the correct or safe form of passing a variable to database: Example one with dots and double quotes ...
0
votes
1answer
20 views

Refactor nested foreach loop based on object property

I'm using a levenshtein matching algorithm to match a title to a filename (for anime). I either use the main show title for matching or its alternative titles (...
1
vote
3answers
41 views

Dimension comparisons for calculating image thumbnail size

I've been toying around with some code I wrote a while back, in an attempt to make it "cleaner" based on what I've read. Does anything stand out to you as bad conventions here? What are your thoughts ...
0
votes
0answers
40 views

A Router I coded

This is router I created for use, however, I wish to refactor this code and make this more robust. I would really appreciate anyone who can: Point out how to make this code more robust, clean and ...
-4
votes
0answers
22 views
0
votes
0answers
33 views

Building JSON array containing HTML

So, One of my companies developers wrote this. Not me. Alright, it was me. How can improve this puke? ...
1
vote
1answer
33 views

Create an associative array with values as an array from an another associative array

I have a query that returns an array or associative arrays of ids and years. It looks like this: ...
0
votes
0answers
37 views

My Users Controller

I was hoping someone could take a look at my users controller and give their feedback based one their opinions of what they think of my user's controller. As well as maybe give some ideas if any for ...
3
votes
2answers
34 views

Single MySQLI query to check for admin privileges

I have this script on top of all pages to check if user is admin otherwise we kick him. The problem is that I don't know if I am using double resources with a double query and results. Can I make this ...
5
votes
1answer
59 views

One way encoding a password

I wrote a script that one way encrypts a user's password by generating a key, and multiplies by the ASCII value of the character and the ASCII value of the key character at (the position that the ...
1
vote
1answer
21 views

Identifying a development and production server by http_host

I am using below code to recognize which set up I need to use in Codeigniter: ...
2
votes
3answers
58 views

A very secure procedural MySQLI login script against injections

I know there are other ways to create a login script like Object Oriented, Prepared Statements and PDO, but how about those old MySQL PHP users like me trying to change from old style to the new ways? ...
0
votes
1answer
35 views

Caching using phpFastCache

I have a class that holds functions for caching using PHPFastCache. There are quite a few static functions in here and for each one I am declaring: ...
0
votes
1answer
37 views

Rover on a grid

I have ridden to much about MVC and SOLID, so I have a mess in my head. I have written a small MVC application and I need your experience and sober mind. index.php - Start point of my app ...
-2
votes
0answers
18 views

Why I have errors with these codes? [closed]

I'm trying to get the values from a Query String and add them to an array inside of an array. The output Query String is something like: ...
2
votes
0answers
53 views

Building the HTML body view

I created a library class in CodeIgniter that handles building the HTML body view. This class builds the body, adds content and adds javascript element tags at the end. The body is built by using a ...
0
votes
1answer
40 views

Syntax form PDO

I was able to run the form to update the data of the user profile, for the moment is in a rough version, but I know that can be improved. I post what I did, I hope you could help me to improve the ...
1
vote
0answers
55 views

Config Loader project in PHP

I have created an open source config loader in PHP, but I wish to improve on the loading of the config files, as I think how I handle the loading is good. At the moment, this is my ConfigLoader ...
1
vote
0answers
61 views

Page Spider in PHP

I have a working spider, however, it runs fairly slowly thanks to Australia's horrible internet. Can anyone give me some tips on speeding this up? ...
3
votes
0answers
20 views

Derive currency conversion rates from database, keep it available in a class

I would like to know whether I applied the SOLID principle and the repository pattern the right way. My code should derive exchange rates from a database and do basic currency conversions. The ...
-2
votes
0answers
19 views

Parse error: syntax error, unexpected 'id' (T_STRING) [closed]

Error: Parse error: syntax error, unexpected 'id' (T_STRING) in /home/u590953899/public_html/posts/index.php on line 27 Line 27: ...
3
votes
1answer
100 views

Handling new user requests from a Swift client

I am starting to play with POST request to save in my server the user token so I can send push notifications in Swift (this is the swift code). This is the PHP file that processes the request (please ...
1
vote
2answers
44 views

Helping a user manage a database

The following code will read a db, show the contents to the user and provide instruments to edit them. This has been tested and works well. model.php ...
2
votes
1answer
53 views

Controller to list users

I think I put too much code in my controller that was supposed to go in the model. This is a part of my controller, I'm not gonna paste everything since there is a lot of code. ...
3
votes
1answer
27 views

Database Plugin for CKFinder users

I have written a small plugin library for CKFinder that I would like some critiques on. The library is located here. If you are looking for where to start, check out plugin.php and hook function in ...
3
votes
1answer
54 views

PHP implementation of “depth-first search” on the graph data structure

As I am a totally self-taught 'person writing code', I decided to learn algorithms with one online course that taught them using Java for demonstrative purposes. The first topic I covered is the graph ...
1
vote
2answers
68 views

Match all youtube links in a string of text

I'm looking to pull all the youtube links from a string of text and was wondering how does this look? ...
0
votes
1answer
40 views

Joining multiple functions data in one array

This bit of code gathers data from two methods and puts it into an array. The code works fine but it doesn't look pretty and I feel like there is a better way of doing what I have done. ...
0
votes
1answer
38 views

Solved the problem. Might some cleanup and/or advise

I wanted to display 1 outcome of 1 single custom field or attribute in the category overview, using a third party customfield extension in my J! and VM website. I got it working using the code below. ...
1
vote
1answer
36 views

Execute script on remote host and obtain variables on localhost

This executes a predefined script on a remote host, and somehow retrieve variable values without affecting STDOUT and STDERR. My idea was to encode the data in JSON, write it to a file, then read the ...
0
votes
0answers
52 views

Creating multiple arrays in PHP

I have a PHP application that generates multiple graphs based on SQL output. I usually use something like the below code to build up arrays ready to be used within the graphs: ...
1
vote
0answers
51 views

Class Object to create objects of type Object, in a dynamic way, with magic methods

I have a project in my mind for quite some time, and it requires me to create dynamic objects. Usually, casting an array to object does the trick (e.g.: ...
4
votes
1answer
52 views

Method for calculating shipping cost

I'm trying to optimize the following method. Any suggestions on how this can be done better? The shipping cost is based on weight and the total cost of products. Following are the conditions for ...
3
votes
1answer
33 views

MySQL class that handles sanitization

I've written a MySQL class that handles sanitization of different data types. The reason I used this (and not prepared statements) is because this can be more dynamic. Prepared statmenets only ...
2
votes
1answer
42 views

Sanitizing function

This is a sanitizing function. Is this function secure enough? ...
8
votes
3answers
234 views

A PHP User System

This PHP User System was built with MySQLi and I also used Composer. I'm planning to improve this, and add more stuff and release it as a sort of a module for Composer. User.php (Controller File in ...
6
votes
4answers
229 views

Create a 2D array from SQL table

I am a beginner to PHP programming. I wanted to make a 2D array that would store the values of a table into the array. Below is the Frankenstein code I created (every time I wanted to achieve a task ...
5
votes
1answer
55 views

For a login portal, what security measures are needed to prevent unauthorized access?

I'm designing a login portal that has one angularjs page that displays/processes data queried from a database. I'm relying on a few php pages (a loginpage.php [verifies credentials/loads session ...
2
votes
1answer
72 views

PHP login system security using a database, cookies and sessions

I created a simple login system using just sessions but having to login every time gets annoying. That is why I'm no trying to save the sessions to my database linked to the user's account. I will ...
2
votes
1answer
46 views

Getting CSS files based on production or development

I have the below script which returns CSS files based on production or development environment. The development section is fine; but for production I have to do 2 loops to get the files. Is there a ...
0
votes
1answer
35 views
4
votes
1answer
55 views

Observer Pattern with an Observer observing multiple Subjects

Is the below a good solution for an observer to monitor multiple subjects. My only fear is that if an observer was monitoring a wide range of subjects then the update method could get quite large ...
2
votes
1answer
31 views

Validate input of month/year, otherwise set it to current month/year

Is there a cleaner way of doing this? I'm using filter_input to first check for valid input, then using it again to assign the variable. Also, my condition in ...
3
votes
1answer
43 views

Validating a User via Save Method

I'm fairly new to object oriented programming here and am trying to get my head around the best way to go about creating Users and Validating them in the system. My first attempt is below and my main ...
2
votes
2answers
62 views

REST API using PHP

I am trying to write an REST API using php from scratch which I am gonna use to play with Angular.js. It is working fine now and I need your opinions on the things I have done in this code to improve ...
-1
votes
2answers
95 views

Simple IF statement, am I doing it right?

Although I have been coding in PHP for a while now I am trying to go back to basics with some things to make sure by understanding and methods are the most efficient. I have the following snippet... ...
0
votes
1answer
43 views

Ajax Done Callback to prevent requests from interrupting each other

I am trying to make sure my Ajax does not send another request before it receives a reply. To the best of my knowledge the code I will post is supposed to do this but I am still getting a -1 for ...
1
vote
1answer
48 views

Laravel photo uploader class

I'm trying to separate logic from the controller, so I created this Upload class. It is not a big class, just a class so that the controller doesn't know about the ...
3
votes
1answer
39 views

Polyglot function to sum all the numbers in an array in Javascript and PHP

This, again, is a very simple code. This is my 2nd polyglot question and this time I've tried to do something that I miss sometimes in Javascript. PHP has the ...
1
vote
1answer
35 views

How do i add prepared statements to this php code?

I'm really a newbie with code, and I wish to prepare all my statements to avoid SQL injection. I have searched a lot on the internet, but this wrapper/API doesn't look anything like the examples ...