PHP is a widely-used, general-purpose scripting language that is especially suited for web development.
3
votes
0answers
11 views
Extension of PHP `round()` for PHP_ROUND_UP and PHP_ROUND_DOWN - follow-up
The original question can be found here.
While looking at PHP.net this afternoon, I saw a comment in round() for two functions for rounding ...
-2
votes
0answers
11 views
1
vote
1answer
16 views
Extension of PHP `round()` for PHP_ROUND_UP and PHP_ROUND_DOWN
While looking at PHP.net this afternoon, I saw a comment in round() for two functions for rounding UP and ...
0
votes
1answer
16 views
Save user input in server-side database
I have created a site for practice and I have already asked a question on Stack Overflow about XSS.
Someone tell me to show your php functions on this site that i created using ...
-4
votes
0answers
15 views
mysql_fetch_array is not returning result [on hold]
Below the //message for the driver comment; $search_loc['location'] is not getting the location in mysql db. I want to be able to retrieve location and email it to driver.
...
4
votes
5answers
98 views
Basic contact form
This is for commercial purposes. It's not going to a database, but will just be emailed to a person via phpMailer.
I am not good at PHP (truly awful). I'd like to know whether this is good enough for ...
4
votes
2answers
46 views
Increase view counter with each page view
My question is similar to before, but now the code has changed completely. I would like to understand if this code is vulnerable to mysql injection.
...
-3
votes
0answers
29 views
Small MVC Application [on hold]
I'm learning the MVC pattern and I want you to show my small MVC application.
I have made a repository on github, because its to much code to post here.
I'm on IIS so I don't have a .htaccess file.
...
3
votes
1answer
32 views
PHP script for getting post data from Tampermonkey script
I'm trying to shorten this piece of my code into a loop:
...
-1
votes
0answers
36 views
Incrementing a view counter [duplicate]
This is a script for count page hits.
Can you please tell me if it's danger to mysql injection?
...
5
votes
1answer
119 views
Pagination PHP function - Can this code be made more efficient?
First of all, I didn't write this code from scratch, I'm pretty sure I took it from an online tutorial and modified it slightly to suit my needs. Can the code be improved in any way? I feel it's quite ...
-6
votes
0answers
17 views
Why doesn't my .php upload file to DB not work [closed]
as the title already gives it away, the following file just simply will not execute. I identified the problem being the moveFile() function calls at the end of the ...
6
votes
2answers
69 views
A class to add and select players within a database
I have a question and want to know if my class is considered object oriented.
...
-7
votes
0answers
26 views
My switch and case isn't displaying data in the desired manner [closed]
This wonderful pice of code:
...
3
votes
1answer
16 views
Bootstrap WordPress Carousel Recent Posts
This works, but I would like suggestions to improve it. For one I think the get posts shouldn't have to be repeated twice, but it only pulls the first two posts if I don't do it this way.
Also, I ...
5
votes
1answer
27 views
PHP Image Uploader
I have a website, where one of the options that a user gets is to change their avatar.
I would like to know if there is anything that I shouldn't or should be doing... So here is what I've got.
Here ...
4
votes
0answers
21 views
Router to match URL to Controller Method
I wrote a router class which accepts a URL and calls the appropriate controller method based on it.
I'm a little worried about the amount of dependencies it has (eg ...
-5
votes
0answers
32 views
get html code by php or ajax [on hold]
I want get html code from one source by ajax or php. So I've written simple elements engine.
...
8
votes
6answers
1k views
Custom algorithm for hashing and un-hashing password
I am attempting to create functions for getting an algorithm, hashing and un-hashing a string.
As it stands, it works, and very well. But, I feel this is not secure enough and someone could easily ...
5
votes
1answer
94 views
Geocoding hook for a TYPO3 extension
I'm currently developing a TYPO3 Extension in PHP and developed a Hook.
TYPO3 has the concept of Hooks where you can execute your own code as specific points. As defined in our definition of done, we ...
3
votes
2answers
32 views
str_replace vs array_map & trim on URL segments
Are there any advantages on using array_map & trim vs using simple str_replace? The ...
6
votes
1answer
42 views
Part of Speech Tagger
I have a Part of Speech Tagger written in PHP that currently takes a relatively long and unpredictable time to execute - just wanted to know if any of you knew of any quick ways I can improve time ...
3
votes
1answer
57 views
Learning with an OOP CMS
I want to learn OOP and I am creating a little CMS for practice and to use it as a base for other projects in the future.
This is the complete code: GitHub
My major concerns are code structure, ...
4
votes
1answer
58 views
8
votes
1answer
69 views
Address filter with PHP using regex
I developed a PHP function to get a not formatted address and split it in a street name and number.
Following are some patterns of received addresses
StreetName Number
SrtreetName, Number
Number ...
3
votes
1answer
22 views
CakePHP static pages (without entity) but with dynamic content
I have a few pages that is not connected with entities (index page, terms of use page, email page).
Detailed description: In CakePHP, when you want to have a static page (such as index for example), ...
4
votes
0answers
31 views
Create a Color Box Image GUI inside WEB
I have been working on a web application that produces an image out of colours. Having multiple divs works, but the load time is slow and until the image loads it's ...
4
votes
1answer
66 views
Creating a configuration Class in php
I am creating a system for a client that loads information from an XML file and then parses the information where needed. For this, I have got this class:
...
3
votes
1answer
38 views
Euler Project 14 - Longest Collatz Sequence in PHP
This is my solution to Project Euler 14:
The following iterative sequence is defined for the set of positive integers:
...
2
votes
0answers
19 views
Change the limit from CakePHP 3 Paginator by click in link inside an <option>
I'm using the CakePHP 3.0 to paginate some content, but I can't find a way to change the limit (user on browser choose the limit of content displayed on screen) using ...
3
votes
1answer
59 views
4 database queries, multiple loops in loops, slow processing time
The octoberCMS(based on laravel) controller below is what I use to select the lowest price in 4 pricelists in the given daterange.
Prices can vary and it's not guaranteed that the more expensive ...
3
votes
0answers
36 views
Raw filter with ternary operator for html class attribute
I've been trying to figure out how to stop Twig escape using the following code, which I feel is a little nicer with the succinct ternary operator.
Hoping someone can confirm I'm using the correct ...
6
votes
5answers
407 views
Function to get rows from database
I have a function that returns rows from my database, and it works fine, but I was told that it was poorly written, and there is a lot of unnecessary code in it. I'm wondering if there is a simpler, ...
4
votes
2answers
63 views
First MVC Router
I'm learning the mvc pattern and today I finished my first mvc routing class.
Hope you can give me some tipps and improvements.
Router.php
...
2
votes
1answer
47 views
Validate data for insert, server side
I have a function for parsing data, that goes to the database, (it's more validation, the sanitization process is taken care of by the framework). Here's my handmade script, based on a jQuery library, ...
7
votes
4answers
874 views
Checking 160,000 records in a database for changes
I am checking over 160,000 records in my database every 24 hours to see if there were changes in the incoming data coming from API and my existing data in the database. If there were I am updating ...
4
votes
0answers
78 views
2
votes
1answer
35 views
Making a grid of videos
In my single-work.php I have some code with slight variations that I feel could be more DRY. When there are only slight variations like this is it ok to repeat part ...
2
votes
1answer
40 views
Using Cache::remember for banners and stores
I'm using Cache::remember to cache 3 results in my action, 2 in the same call to Cache::remember. It works, but I have 2 ...
3
votes
1answer
130 views
4
votes
1answer
43 views
php sqlite query with mulitple replaces
I have a column where, pretty much, each entry has numbers (specifically #1-4) and spaces (' '). I wanted to make a query that could avoid having to know these numbers and spaces. This is my working ...
1
vote
1answer
38 views
List of variables, split based on pattern
In my application i keep repeating writing this pattern. I just cant figure out how to write it better. Coming to you for suggestions:
...
5
votes
1answer
64 views
HTML content from database results
This code produces HTML from the results of a database query.
Self-taught, I have concerns about developing bad habits and I wrestle with the principles of OOP and MVC.
I would be grateful for your ...
5
votes
2answers
43 views
Static utility functions to turn arrays into SQL statements
I have an object that houses only static functions. The functions are stand alone and are not dependent on the state of the object.
I hear that static functions are a nightmare in terms of testing, ...
2
votes
0answers
50 views
Controller method to add a product, stored across three database tables
I have some questions on how I can improve this "add" action method in a controller.
Using a single form, the user can upload a product to be displayed on the site. A Product is composed of three ...
1
vote
1answer
40 views
CakePHP login action returning json
I have some questions on how I can improve this "add action" (method) in "controller":
I'm using the add action only if post request. Is it correct?
This ...
4
votes
1answer
71 views
CakePHP change 'miniMap' action and respect template
I have some questions on how I can improve this "action" (method) in "controller":
My template has a navbar with dynamic content (if the user is logged in a special button appears, his name appears ...
1
vote
1answer
70 views
CakePHP image upload component
I would like to know how I can improve this CakePHP 3.0 Component (inside folder controller)
1st: to use external libs (stored on vendor folder) I'm using the ...
0
votes
0answers
63 views
Inserting a first name into a name table [closed]
I'm trying to create a secure website. Can someone let me know if this is susceptible to SQL injection? If it is, could you provide me with an exmaple of a statement that would work for injection? ...
6
votes
2answers
97 views
Using PHP to create a file structure
I am using PHP to create a file structure in which to store XLSX files, for this I have created this class:
...