PHP is a widely-used, general-purpose server side scripting language that is especially suited for web development.
1
vote
0answers
11 views
Performance on PHP sql queries
I'm barely learning PHP and MYSQL so I don't know much about performance, I've wrote this script to fetch and format content from my DB, it also counts how many result are and separate them in to ...
4
votes
1answer
13 views
SQL - query syntax
I need advise whether my database structure is correct and what is the appropriate query syntax that can be used.
Table1
...
1
vote
0answers
13 views
Wanting to convert current code, to code that matchs coding practises
I've dabbled with PHP for a couple of years, I can generally get what I need done and I've been teaching myself PDO. The problem is I want to set it up with classes but i'm not really sure how to.
...
0
votes
0answers
15 views
Include Multiple Database Connections Inside a PHP Class
I've a simple PHP class file and i Want to include multiple database connections, since each of my functions using different databases for fetching information.
The files to be included in the class
...
-4
votes
0answers
18 views
why my php/mysqli code doesn't work? [closed]
I have written this code for check user data exist in db :
$username = $_POST['username'];
$email = $_POST['email'];
$mobile = $_POST['mobile'];
$SQL = "SELECT ...
0
votes
1answer
30 views
PHP MVC - Custom Routing Mechanism
Note: My code currently works well and I've progressed further than this - however I feel that this router is, frankly, crap, and I'm looking for honest opinions and constructive criticism.
I'm ...
1
vote
0answers
32 views
Is it possible to sniff a file location using this force-download script?
I'm making a WordPress plugin that obfuscates the real file URL and forces the download of one of this 3 types of URL:
Local: http://example.com/wp-content/custom/filename.zip
Dropbox: ...
1
vote
0answers
22 views
PHP - Optimize array manipulation
In this function I am trying to initialize a $data object with defaults from metadata about the class ($this->_fields) as well as transform the value for each class to a native PHP value.
For ...
5
votes
2answers
37 views
Autoloader class
Depending on your directory structure you may have name spaced class files in different directories (that isn't really part of the structure, i.e. lib/ or core/).
Symfony ClassLoader is awesome, but ...
1
vote
0answers
27 views
Is this PHP Email Form Secure from injections or other abuses?
I am new to PHP and put this contact page together using the w3Schools.com example as a guide along with a couple other sources. As far as I can tell, it works fine, but before I put it up on my page ...
3
votes
1answer
39 views
framework design review (SOLID)
I'm developing a php framework for educational purposes, I have learned a big deal about design patterns and MVC.
I've been thinking a lot on how to have a nice design and so far I've come up with ...
3
votes
2answers
60 views
Potential Problems with this templating technique
I like the way Zend Framework works it's views and I make extensive use of partials but every partial include results in it's own file system hit. As I'm building my own framework I thought I could do ...
3
votes
1answer
42 views
Dynamic homepage with PHP - making things too complicated?
I am trying to show the 6 most popular products on my homepage from left to right, in two rows. My code actually works... but I have the feeling I am making things way too complicated. Is there a ...
1
vote
1answer
40 views
Router Class In a Lightweight MVC Boilerplate
I'm trying to come up with a simple router class. I considered using a Request class but that will rather make simple to complex. That is why I did not consider creating one for my framework.
class ...
-4
votes
0answers
52 views
I've spent a month without washing, shaving or leaving my office [closed]
Can you please look over
http://www.interimspaces.co.uk
and tell me what you think.
specifically - problems and feedback.
THank you
0
votes
2answers
57 views
How is this for an API structure
I have just written an API framework which I am hoping to implement into one of my large sites very soon. However, before I do so, I want to be sure that the script is well written and there are no ...
1
vote
1answer
49 views
PHP: Random imgur image loader
Just a little thing I made to load 20 random images from imgur. I looked at the way that imgur references images on its site, and I felt like I could probably generate a random string of letters and ...
0
votes
1answer
34 views
improvements to this php function to calculate monthly returns from a set of price data
I have made this function that should take a set of price data and calculate a set of monthly returns. The idea is that is should be able to cope with irregular time intervals.
For example I have ...
3
votes
1answer
94 views
Improvement of my php code
I wrote a class with this function. Can I improve my code performance in the bottom of the function? I don't like the while loops!
public function loadFields(array $fields, $as_object = ...
2
votes
0answers
15 views
ZF2 Model Mapper
In the ZF2 model mapper, mappings are quite often duplicated in the original mapping class & other mapping classes.
I am using a static mapping methods (mapToInternal, mapToExternal) to remove ...
2
votes
1answer
45 views
Can I do something better in that code? And improvements?
Hi guys, simple question!
Can I do something better with the code I wrote.
It's running problem less. It's just a snippet of a library I wrote.
Thank you for all answers!
<?php
/*
* ...
0
votes
0answers
30 views
CakePHP Ticket Component
I have the following code that allows easy creation, pulling, and deletion of Tickets in a CakePHP application.
App::uses('Component', 'Controller');
App::uses('Ticket', 'Model');
...
1
vote
1answer
57 views
How can this layered PHP architecture be improved?
This is my first "large scale" system I've designed for myself. Since I'm more of a front end developer than backend developer, I'm not sure if my architecture is sound.
I've created a Factory class ...
0
votes
1answer
53 views
Something wrong with this code? [closed]
Hey been at this for a day can't fix the problem.
This function updates user info in the db [MySQL]
it keeps throwing the exception Couldn't update user
<?php
function update_user($user_id, ...
1
vote
2answers
37 views
PHP PDO mysql multiple queries mak
I ran into a problem, I'm using MyIsam tables in mysql database, using PDO to connect.
In all my tests (calling for 1 user everything works fine), now having around 300 users connected at the same ...
2
votes
2answers
61 views
Best way to structure PHP AJAX handlers?
I'm just getting started with AJAX and am unsure of the best way to structure a PHP AJAX handler. I created a PHP file, ajax_handler.php, and the way I have it structured now is just a bunch of ...
1
vote
1answer
31 views
Review of template parsing function
I am using preg_replace_callback(), and I am concerned that I might have some sort of security risk. I am hoping to get a review of the below substitute() function. The purpose of the function is to ...
-1
votes
0answers
33 views
Object Oriented PHP - mysql database manipulation [closed]
Been working with this code but it won't run. Please help me find the problem with this.
THis is my class :
<?php
class mysqlcon
{
private $connection;
private $database;
public $query;
...
1
vote
1answer
79 views
Array inside array (comment system with 2 levels)
I have a comment system on 2 levels (like Blizzard http://eu.battle.net/sc2/en/blog/7935264/#c-7257875753), it's working fine but my code is a bit dirty :
// $datacoms array from mysql_query
...
1
vote
2answers
36 views
Please tell me if it is a good controller or not. Would really appreciate
<?php
session_start();
include_once("model/Model.php");
class Controller {
public $model;
public function __construct()
{
$this->model = new Model();
}
public ...
2
votes
1answer
30 views
I made a PHP contact form that goes to multiple addresses based on drop down selection, how do I determine if my code is safe?
I followed a tutorial to create a PHP contact form that sends to multiple emails depending on drop down field selection. I have included the PHP below. Is it protected from spam/other dangers? Or is ...
2
votes
1answer
98 views
I need someone to check this out to improve it
Takes a name, 2 images and a birthday for an artist, uploads images and insert info into MySQL, I seem to be missing something and I'm looking to see if i'm following best practice.
<?php
...
2
votes
1answer
51 views
My login with AJAX and PHP
In your opinion, do I need to do all these validations. I thought to do well and stay safe but I seriously raises the question if it isn't slower.
jQuery code
$(document).ready(function () {
...
4
votes
1answer
58 views
Code Reiview for an PHP PDO Queries? is there a better way to do it?
so this is my code for a equipping an item in my game dev't:
try {
$db = getConnection();
$db->beginTransaction();
$sql_chara_gold = $db->query("SELECT chara_gold ...
1
vote
2answers
49 views
Using AJAX to look up MySQL value using two dropdown inputs
I have a list of cities, and a set of "travel time" between any given two cities. The "travel time" is fixed and not necessarily dependent on absolute distance between the two cities, and it currently ...
1
vote
1answer
35 views
Critique my wordpress PHP code
PHP/programming noob here. I'd appreciate a critique on my code (wordpress) and how I could make it more efficient (rather than repeating the if statements.
What I'm basically doing is getting the ...
2
votes
0answers
38 views
Practical advise for CMS
I'm working on a CMS system. The basis is pretty much done but before going any further I would like to know if there are things I really should change in the way I code things.
I am pretty sure ...
3
votes
1answer
110 views
Learning PHP, wanting observations on some code re glitches / gotchas / better practices etc
G'day
I'm in the process of cross-training myself from CFML to PHP as part of a learning exercise. I'm learning from the docs and online tutorials and googling. As I'm working by myself I have no ...
1
vote
3answers
20 views
How I can call restful web services efficiently
My code is as follow
I need to use this code to fetch data from web service and show them in a site properly but after I request for the webservice I am unable to load them fast. Site is loading very ...
6
votes
2answers
192 views
Where should I define my entities?
I am working on my own PHP MVCframework. Now I want to know where to get and specify my entities.
An example, should I do this:
class User_Model extends Model {
private $name;
public getName() {}
...
2
votes
3answers
218 views
My perfect shopping cart class
Here is my shopping cart class! I want it to be perfect and never to have to implement it.
What improvements would you do?
New : IComparable
interface IComparable
{
public function ...
3
votes
4answers
265 views
Best practices in PHP
I've posted here before and got pretty helpful reviews. So, how does my code look now. To keep it really helpful, I just copied this from the middle of one of my projects. Review please?
<?php
...
3
votes
1answer
59 views
JavaScript object to JSON
Since I didn't find a way to properly transform JavaScript object to JSON with PHP, I wrote a snippet.
Lets assume the following excerpt from Google Fonts JavaScript API:
WebFontConfig = {
...
2
votes
1answer
72 views
How to create a simple stateless cache class in PHP
i need to create a cache class to avoid making the same calculations more than needed. My idea was something really basic like
class transient_cache {
static private $cache = array();
static ...
3
votes
1answer
50 views
Have I missed some obvious XSS vulnerabilities?
As the question states: have I missed some obvious security vulnerabilities in this code? Particularly interested in XSS...
I'm trying to create something more robust that strip_tags, but simpler ...
2
votes
1answer
84 views
Delos MVC PHP Framework
I've been working in PHP since almost three years ago. In this time I built a framework as base for my projects.
I want it to be improved, and which other best option there are that use ...
0
votes
2answers
72 views
Improve nested IF structure
Alright guys,
Basically i'm putting together a little application and it requires about 6 if statements to verify actions, here's the current code i'm using.
if($player[0]['value'] == ...
1
vote
2answers
81 views
What is the best way to get the child class name for use in a parent class
I am currently trying to implement a very simple MVC framework as a way of helping me understand how they work. My base controller class has 2 properties, a model and a view. All controllers have a ...
1
vote
1answer
29 views
Assign value of nested array as array key
I have a multi dimensional array like this:
[0] =>
['batch_id'] => '1'
['some_stuff'] => 'values'
[0] =>
['unit_id'] => '12'
['some_stuff'] => 'values'
...
1
vote
2answers
47 views
Wordpress php Contact Form - Security flaws
I have the following contact form included with my wordpress theme as a template.
Now a user on Stackoverflow pointed out that this form has some serious security vulnerabilities.
Could someone ...



