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

learn more… | top users | synonyms

0
votes
0answers
23 views

MySQL vs PDO execution time

I'm having some issues understanding why PDO is 6X slower executing a query than the depreciated MySQL query function. Here's my code: $conn = new PDO('mysql:host=localhost;dbname=work', 'root', ...
0
votes
1answer
21 views

Need to clean up my code and add the ability to resize the image

I have the following code: <?php include '../../inc/config.php'; $size = isset($_REQUEST['size']) ? $_REQUEST['size'] : 'full'; $image = isset($_REQUEST['image']) ? $_REQUEST['image'] : FALSE; ...
1
vote
1answer
37 views

SQL Query efficiency within class

I'm trying to figure out whether I should do the following: This class (over-simplified version) retrieves information about an order by having 1 main query function that select a specific column ...
1
vote
1answer
49 views

Anyone have some ideas about my code?

I have this class that pulls people out of a database. I want it to be a little prettier and function better. Anone got ideas? Feel free to ask questions :) <?php class comps extends db_config { ...
0
votes
0answers
17 views

Extract equally from X queues to one queue with Y elements

I need to implement a system of queueing that extracts elements equally from x queues to one single queue with y positions. Let's say I have 5 queues, each with a number of elements and I need to ...
3
votes
1answer
72 views

Generic method for database calls

Background Breaking from MVC, I've implemented the following architecture: POST/GET ➤ PHP ➤ Database Calls ➤ XML ➤ XSLT ➤ HTML All database interactions are relegated to the call method in the ...
3
votes
1answer
33 views

Improvement on code

Okay, I'm just a little newbie in programming just doing it for a past time hobby. I am just recently making a web editor for fun and the way I was doing it (Using PHP) I was told would be a bad way. ...
-1
votes
2answers
30 views

WebSite stucture with PHP [closed]

Can you help me to write my rewrite rules for this page. When I write : contact.html?id=2 I want get : index.php?location=contact&id=2 That's my index page. <?php ...
1
vote
0answers
27 views

PHP Templateing Engine That uses closures to eliminate iterative includes

This is the second submission for Code Review for this project but since the API changed considerably I felt it should not be taped onto the original post. To see the original post and comment see ...
3
votes
1answer
47 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
2answers
43 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 ...
3
votes
1answer
34 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. ...
-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
49 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
1answer
50 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: ...
5
votes
2answers
75 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
3answers
63 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
48 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
71 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
46 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
51 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 ...
0
votes
2answers
60 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
62 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
35 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
110 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
22 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
48 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
60 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
42 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
84 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
32 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 ...
-2
votes
0answers
42 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
80 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
32 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
103 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
56 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
62 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
68 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
40 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
43 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
116 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
29 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
200 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
260 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
365 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
63 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
75 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 ...

1 2 3 4 5 19