php

PHP framework (cake/smarty): How to use it and when?

Duplicate of What is a PHP Framework? and many more So far, I've been using PHP for small tweaks, mostly with WordPress. What are PHP frameworks? Why do I need them? WHEN do I need them? Any insight will be helpful. Thanks. ...

Magento SSL links

Hi all, I've configured magento to use SSL links.. Base URL https://sub.domain.com/ Base Link URL {{secure_base_url}} Base ... URL {{secure_base_url}}.../ Use Secure URLs in Frontend: YES Use Secure URLs in Backend: YES Frontend i have some custom links built with Mage::getUrl([...]) <?php // link to CMS page echo Mage::get...

How do I make Win32 API calls from PHP?

I know that I can consume COM components but is there a way to directly call into the Win32 API's (user32.dll, advapi32.dll etc) from PHP or do I need to wrap in a PHP extension or COM object? ...

How to show a post right after posting like SO with PHP?

Currently I'm doing this in two steps: 1.post it to ask.php 2.after inserting it into database,use header("REFRESH: 0;URL=post.html") to jump to the result page But how to do it all in one step,say,like SO here? ...

check filename before posting using jquery/ php

Hey. I need jquery to check if my posted filename (up_image) is empty or not. if it's empty i need a div tag to be shown and come with some kind of alert message. if not, just do the $("#submit").submit(); <form action="/profile/" method="post" enctype="multipart/form-data" id="submit"> <p> <label for="up_image">image...

How to save XML file to host?

I use DOM to read and write XML file but it don't work. My code like this: <? $dom=new DomDocument(); $dom->Load("http://localhost/xml/file.xml"); $root=$dom->documentElement; ... $dom->Save("file.xml"); ?> It not work. But when i try $dom->Save("C://file.xml"); It work fine. I don't understand while it not work. Anybody can tel me ...

Determine Which Part(s) of WHERE Statement Failed

Let's say I have a SQL statement like this that checks a user login: SELECT * FROM users WHERE username='[email protected]', password='abc123', expire_date>=NOW(); Is there a way in SQL to determine specifically which WHERE conditions fail, without having to separate each condition into its own query and test individually? In this sp...

Why call mb_convert_encoding to sanitize text?

This is in reference to this (excellent) answer. He states that the best solution for escaping input in PHP is to call mb_convert_encoding followed by html_entities. But why exactly would you call mb_convert_encoding with the same to and from parameters (UTF8)? Does this have some sort of benefit I'm missing? ...

What character replacements should be performed to make base 64 encoding URL safe?

In looking at URL safe base 64 encoding, I've found it to be a very non-standard thing. Despite the copious number of built in functions that PHP has, there isn't one for URL safe base 64 encoding. On the manual page for [base64_encode()][1], most of the comments suggest using that function, wrapped with strtr(): function base64_url_e...

How do you prevent inline <?= text ?> statement from messing up the displayed source code?

In PHP, whenever I do something like: <span>Blah blah HTML</span> <?= echo $this->foo ?> <br /> In the source it displays like this: <span>Blah blah HTML</span> {$this->foo whatever it is} <br /> Instead of <span>Blah blah HTML</span> {$this->foo whatever it is} <br /> Stuff like this happens all of the time. Inline PHP make...

How do I programmatically check whether a GIF image is animated?

Here is a link to another question I asked concerning the same project I am working on. I think that bit of background will be helpful. For those that are too lazy to open a new tab to that question, I'll summarize what I'm trying to do here: I've downloaded about 250,000 images from 4scrape and I want to go through the GIFs and find w...

Identify development vs. production server in PHP

I work with two application servers on a daily basis: one development, one production. A variety of apps from different developers live on these boxes, as well as some scripts that run via cron. Currently, I am using the -D flag to httpd so that I can identify my production server in code, ie. isset($_SERVER['DEV']). Unfortunately, this ...

PHP 2-dimensional array -> how to convert to HTML table syntax?

Hi! I need to read a bi-dimensional array and convert the values into an HTML table. For example: $grid = array( array(0,0,0,0),array(0,0,0,0),array(0,0,0,0),array(0,0,0,0),array(0,0,0,0)); $grid[0][0]=4;$grid[0][1]=4;$grid[0][2]=4;$grid[0][3]=4; $grid[1][0]=3;$grid[1][1]=3;$grid[1][2]=5;$grid[1][3]=5; $grid[2][0]=3;$grid[2][1]=3;$grid...

Code Addition is Slowing Page Down

My client ordered another addition to the script, but I can't figure out how to fix the slowdown? The table has about 50,000 rows. while($stats = mysql_fetch_array($get_stats)) { if ($stats['ip'] == gethostbyaddr($stats['ip'])) { // new code $is_undef = "Yes"; // causing problems } else { $is_undef = "No"; } // e...

Symfony - Override sf_format when calling get_partial.

I'm making an AJAX call in my symfony project, so it has an sf_format of 'js'. In the actionSuccess.js.php view, I call get_partial to update the content on the page. By default it looks for the partial in 'js' format since the sf_format is still set as 'js'. Is it possible to override the sf_format so that it uses the regular 'html' par...

Selecting a single row in MySQL

I have a table that has nine columns in it. one of them is the primary key. How can I select a single row, and all of the columns in it, by the primary key or column 8 or 4? I'm using PHP and MySQL ...

How to implement cascading deletion of hierarchical data in MySQL?

Hi, I'm working on a project that has categories / subcategories. The database table for this is unique, with the following structure : CREATE TABLE IF NOT EXISTS `categories` ( `id` int(11) NOT NULL auto_increment, `publish` tinyint(1) NOT NULL default '0', `parent_id` int(11) NOT NULL default '0', `description` text NOT NULL,...

Interview question: In php, is 123==0123?

I have answered it is false. then he asked why? i couldn't answer. Can anyone make the answer? I am very interested to learn it. ...

Doctrine query memory usage

Doctrine appears to be taking well over 4MB of RAM to execute a single, simple query: print memory_get_peak_usage()." <br>\n"; $q = Doctrine_Query::create() ->from('Directories d') ->where('d.DIRECTORY_ID = ?', 5); $dir = $q->fetchOne(); print $dir['name']." ".$dir['description']."<br>\n"; print memory_get_peak_usage()." <br>\...

any open source libraries to extract photo/video attachments from email and/or MMS which take care of "hundreds" of test cases

I want to allow users to upload photos and videos with their mobile phone by sending the photo/video to an email address. Cal Henderson in "Building Scalable Web Sites" mentions that Flickr has "hundreds" of test cases to deal with the fact that "Wireless Carriers Hate You". Are there any open source projects/libraries that try to addr...