php

use Img source with php variable?

hey guys, i have the following code in my detailansicht.php: <div class="file_description_box"> <b>Beschreibung:</b><br /><br /> <?php if(!empty($beschreibung)) echo '<div align="center">'; echo '<img src="$coverlink" alt="Cover">'; echo '</div><br />'; echo fo...

PostgreSQL: best way to create new/duplicate existing tables every year

Hi guys, referring to this question, I've decided to duplicate the tables every year, creating tables with the data of the year, something like, for example: orders_2008 orders_2009 orders_2010 etc... Well, I know that probably the speed problem could be solved with just 2 tables for each element, like orders_history and order_actual,...

How good is PHP performance?

This is a follow up to a recent post I've seen which suggests that PHP performance is poor: "PHP. IS. ALWAYS. THE. BOTTLENECK. My server farms, let me show you them! PHP Overall Performance" followed by: "PHP performance is frickin' abysmal. I am basing this on my experience with OpenX (on Linux) and WordPress (on win64)." Can we get...

Faster to query in MYSQL or to use PHP logic

I have a page that will pull many headlines from multiple categories based off a category id. I'm wondering if it makes more sense to pull all the headlines and then sort them out via PHP if/ifelse statements or it is better to run multiple queries that each contain the headlines from each category. ...

multidimensional mixed associative/numeric array shifting

hi everyone, i have an issue i need to fix sooner than later. if i had the time to rewrite the entire script i would, but such is the life of a programmer, right? anywho, i've taken over a project and i have a multidimensional mixed associative/numeric array like so: Array ( [item1] => Array ( [dataset] => Array...

Checking String for illegal characters using regular expression

Dear all. I want to check a for any illegal character using the following regular expression in PHP. Essentially, I want to allow only alphanumeric and underscore (_). Unfortunately the follow piece of code does not seem to work properly. It should return true if there is any illegal character in the string $username. However, it st...

PHP Session not working in PHP5

I have 2 pages: login.php and index.php. Both pages start with session_start(); When I set $_SESSION['user'] = "name"; in login.php and than open index.php, my session object is empty. How come? EDIT: I found the problem: IE 7. I had to grand access to my domain. However, I thought a session is stored on the server, instead of ...

Best way to get post info into variables without displaying them in Wordpress

I am writing a Wordpress plugin and need to go through a number of posts, grab the data from them (for the most part title, permalink, and content), and apply processing to them without displaying them on the page. What I've looked at: I've looked at get_posts() for getting the posts, and then getting title via the_title(), content v...

can i post a temporary file name of the file that is being uploaded using jquery

hi , i need to post a form which includes personal details and i need to upload a attachment file also and i need to achieve this using ajax , how can i upload a file using ajax , i need to post the personal detail as well as upload a file at the same time using ajax , how can i do this? ...

Memcached on EC2

Am I right in thinking that until I am able to afford dedicated servers or have any spare servers, I could successfully run a small number of memcached servers through EC2? With the annoucement of the new auto-scaling and load balancing by Amazon today, do you guys think this would be a viable option? And what would be the basic techni...

Staying consequent when working with large scale projects.

Hi there folks. Probably a bit off topic question, but it's something I'm really interested in getting to know from other people with different experience and backgrounds. How do you keep track of your huge projects? Do you use subversion? EER-models? Do you write notes? Does all your faith lie in phpdoc? Which framework do you use, and...

In CakePHP, what is a good way to exit or return from controller's methods?

In methods of controllers, there are usually many checks for "doing the right thing". For instance, I check if user is accessing the right data. However, I'm wondering what is the best way to return or exit from these methods when errors do occur. I've been using just simple return statement, but is there anything that's more CakePHP-li...

Why do all my auto-generated thumbnails with GD in PHP have black backgrounds?

Well I am using the following code to take any old image into a 160x120 thumbnail, the problem is if there is overflow the background is always black. I've been snooping around the PHP docs but none of these functions seem to have any kind of color parameters. Any ideas or pointers would be great! $original = 'original_image.jpg'; $th...

Extract data from PHP Object

I'm using the Facebook API and the class produces this object. object(User)#4 (5) { ["fbc_uid"]=> string(9) "324234324" ["fbc_first_name"]=> string(5) "James" ["fbc_last_name"]=> string(5) "Proud" ["fbc_name"]=> string(11) "James Proud" ["fbc_email"]=> NULL } How do I ...

Refactoring PHP code that outputs csv with formulas

I have some PHP code that is designed to make a spreadsheet with formulas already in it to sum some columns. It seems there should be a much more elegant way to do this than the code below. What are some refactorings or design patterns that could accomplish something like the code below better? <? echo ",Current Milestone,Total Hours,Mi...

how do I add an unknown selection of inventory items with a user supplied quantity to a cart?

I'm currently using PHP, JAVASCRIPT, MYSQL, XHTML, CSS to develop my site. Note that solutions are not limited to this but preferred if possible. I have a large MYSQL table of widgets and a page that allows the user to search for a specific widget. Let's say for example the user types the model name for some widget, the search could ...

why would shorthand PHP opening statements not be working?

I am trying to get my Mac setup as a php server, however, as successful as I have been so far, I seem to have run into a bit of bother. My PHP opening statments are not working... but only the shorthand ones. This works: <?php phpinfo(); ?> This doesn't: <? phpinfo(); ?> It's Mac 10.5. Hope that someone can help. Thanks ...

Mysql ORDER BY using date data row

I have a query something like this: SELECT title, desc, date FROM tablename ORDER BY date ASC, title ASC; Works fine when the data actually has a date. Issue is, date submission is optional, so I sometimes get 0000-00-00 as a date, which has the unfortunate effect of placing all nondated rows on top. So, I then tried this: S...

PHP memory profiling

What's a good way to profile a PHP page's memory usage? For example, to see how much memory my data is using, and/or which function calls are allocating the most memory. xdebug doesn't seem to provide memory information in its profiling feature. xdebug does provide it in its tracing feature. This is pretty close to what I want, except ...

How can you set-up PHP + xDebug + (x)Unit + Eclipse to work with breakpoints in unit tests?

Hi guys, Have tried for quite some time to get this to work correctly but to no luck. Basically, I have Eclipse (3.3) with PHP Development Tools (PDT), and the PDT XDebug plugin as well as the SimpleTest eclipse plugin. What I want to do is debug code invoked by SimpleTest unit tests. SimpleTest clearly can see XDebug, because I can ge...