php

Upload image, create its thumb then save

Let's say I uploaded and image. I can get its tmp dir then save it with move_uploaded_file() but what if I wanted to also create a thumb and save bothin some folder? I know how to save the uploaded image, but I don't know how to start manipulating an image and save it after creating a thumb ...

PHP & MySql versus .net & sql server

We are planning to do a large application, and we are tented to do it in php and mysql, because of it cost, but this application might grow a lot, and the database engine could have thousands of connections per second, so I am not sure what technology could handle this volume better. I would like to know what technology I should use, and...

Doctrine relation lost on record update

I'm using Symfony and Doctrine, and have several many-to-many relations that work fine. But there is a table called "document" that holds documents that can relate to several kind of contents, and has an admin section of it's own. Whenever I update a Document, every relation it had to the rest of the tables is lost. I Googled it for a...

Generating a random number complying a specific pattern

I want to generate a number that contains 14 digits. But I want to generate it in a certain pattern. Consider the following number: 292 0505 150 0253 The bold numbers are constants 0505 is a day and a month meaning 05 is the month and 05 is the day. So when generating the random number the first part must be from 0 to 12 and the ...

"Magic" constants in C# like PHP has?

I am building a logging control for a C# project and would like to be able to call it with the name of the current source code File, Line, Class, Function, etc. PHP uses "magic constants" that have all of this info: http://php.net/manual/en/language.constants.predefined.php but I don't see anything like that in the C# compiler language. ...

dealing with javascript enclosed in a php string

so in such situation you lose the javascript highlight syntax, to me it looks like there are some cases were youre obliged to put the Js in a php string (for example when working on some ajax stuff and php mysql request), how you do? i found very annoying to work js this way echo '<script> $(function(){ $("select#discipline_").change(fu...

IE cannot interpret my flash player because of a question mark, but every other browser can

Hey guys, I have another really annoying problem in IE. I am using a php mp3 handler script that I use as a parameter, but it seems to mess everything up just because there is a question mark after .php for my get variables. If I remove the question mark (mp3_handler.php?), the player appears, but with the question mark, it shows up as a...

Mercurial - keeping deployed and development repositories

I am working on a PHP website where I have just added a switch for what environment it is running in - development for when it is running on my local site, and production when it is running live on the web host: <?php define('ENV','development'); //or define('ENV','production'); I have the site under VC with Mercurial, and usually sim...

Preferred formatting for this / best practice?

Suppose I want to create a select box in PHP. $months = array ('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'); Option 1: <select name="month"> <option value="">Month</option> <option value="">-------</option> <?php foreach ($months as $monthNum => $month) { ?> <option value="<?php echo $monthN...

Sort the admin area of a Wordpress custom post type by a custom field

It was easy enough to get my custom fields to show up as columns in the wp-admin area of my custom post type but now I need to sort by one of those custom fields. Any ideas? ...

CakePHP not showing flash() messages?

I am writing a CakePHP app but it doesn't seem to be showing flash() messages on any of the pages. I am using $this->Session->setFlash(); to set flash() messages and using $this->Session->flash() in my default template, as well as $this->Session->flash('auth') on the login and registration pages but they don't show the validation errors ...

gettext works in one file and not the other?

Hi. I have a little trouble getting gettext to work. I made a simple test file where I call the translate.php and echo T_("XXXXX") and It get translated, but when I try to use echo T_ in a function it doesn't work.. translate.php: <?php error_reporting(E_ALL | E_STRICT); // define constants define('PROJECT_DIR', realpath('./fun...

Problem detecting forward slash in preg_replace regex pattern

I am running preg_replace across a string which may contain street numbers. The pattern I'm using is: ([A-Za-z0-9]*)/i This works fine for numbers such as 1, 1a, 123 etc. However it does not pick up street numbers like 1/54B I tried to add a forward slash to the pattern like this: ([A-Za-z0-9\/]*)/i But it isn't picking up number...

PHP & Wordpress: headers already sent - what to do?

hey guys, i'm working on a wordpress template where files of my ftp get listed. if i click on a file I call d.php (d=download) where i simply pass along the path of the file and I want to force a download with header('Content-Disposition: attachment; filename="'. $file .'"'); This is not working for me, because the browser keeps tell...

!is_null() not working as expected

dispatch_address_postcode isn't mandatory and it will still run even if it's blank: if (!is_null($_POST['personal_info_first_name']) && !is_null($_POST['personal_info_surname']) && !is_null($_POST['personal_info_email']) && !is_null($_POST['personal_info_telephone']) && !is_null($_POST['dispatch_address_country'...

Jquery and Cakephp, where to put the file / how to call it?

I'm confused by this as I can't find good documentation on how to do this, I have a jquery file called "index" located in my cakephp site folder at: /app/webroot/js/index.js I am trying to include it in my view with: <?php echo $javascript->link('index', false); ?> but I get: Fatal error: Call to a member function link() on a ...

Need your help with creating an invoicing application using php

Hello, I am working on a php and mysql based client and invoice management web application. In my apps Invoice section, I want to allow users to add any number of invoice items (qty, description, price) dynamically (by default only one will be displayed), and autogenerate total, grandtotal amount. I want to do this using jquery. And wh...

Why use XML as a storage format?

Possible Duplicate: When is it OK to use an XML file to save information? What's up with everything using XML as a storage format for configuration files such? I'm asking because [name retraced] framework has an XML configuration file to store database credentials, and the particular application that's built upon the framework...

Ajax & PHP - can't find session cookie?

hey guys, i'm having a little problem. I'm working on a wordpress template which lists all files on my ftp. Therefore i ask for the the password and pass it straight along to the ftp_connect. So the structure looks like this. I'm asking for the password, and if entered (and send) i'll include a file called ftp_include.php which lists ...

php $_SESSION array not retaining values stored from previous pages

I am trying to create a form where there are multiple sections. It is actually an online menu ordering system. If you remain on the same section (say.. Appetizer), the values successfully load into $_SESSION and displays in the textbox as value. However, if you switch sections (say.. Soups), the values first loads. But when you submit yo...