php

How to make a file extension downloadable?

I'm trying to download http://www.downway1.com/dota/eng/DotA%20Allstars%20v6.67.w3x this file. But it's not able to download. It's opening unknown text. How I can set it up? Maybe I can use htaccess? but how ? ...

Example of a PHP function that returns XML

I need sample code for a PHP function that returns XML. ...

Trying to build a contact form for my lil website but I recieve a mailserver exception!

I realize that I need to use a mailserver so people can contact me, my question is, how can I set one up on my local machine so I can test it? I have XAMPP installed with PHPMyAdmin and I'm just toying and learning with it. Now, in my PRODUCTION server, what email should I use to send users comments to me? I'm really new and need some ...

PHP: Proper way of using a PDO database connection in a class

Trying to organize all my code into classes, and I can't get the database queries to work inside a class. I tested it without the class wrapper, and it worked fine. Inside the class = no dice. What about my classes is messing this up? EDIT: The problem is that it won't query the database and return a result. Any result. class ac { ...

Live Code Editing

Anyone know of a code editing platform that allows users to collaborate in a live environment? For example, google docs but for editing PHP code with others? ...

PHP/MySQL database connection priority?

Hello, I have a production database where usage statistics reside. This database is responsible for many other things (not just statistics calcs). I use php to periodically roll up different resolutions (day, week, month, year) of interesting statistics in buckets dictated by the resolution. The php application I've written "completes"...

PHP Key name array

I have an array $data fruit => apple, seat => sofa, etc. I want to loop through so that each key becomes type_key[0]['value'] so eg type_fruit[0]['value'] => apple, type_seat[0]['value'] => sofa, and what I thought would do this, namely foreach ($data as $key => $value) { # Create a new, renamed, key. $array[...

How to get aggregate days from PHP's DateTime::diff?

$now = new DateTime('now'); $tomorrow = new DateTime('tomorrow'); $next_year = new DateTime('+1 year'); echo "<pre>"; print_r($now->diff($tomorrow)); print_r($now->diff($next_year)); echo "</pre>"; DateInterval Object ( [y] => 0 [m] => 0 [d] => 0 [h] => 10 [i] => 17 [s] => 14 [invert] => 0 [days] => 6015...

Does Propel know when an object has been soft-deleted, so that child entities could still show their deleted parent?

Hi, I am soft-deleting objects in a MySQL database and using the Propel ORM. I have gotten soft-deleting to work, but at the cost of losing my enforced parent-child relationships, since the actual rows are not being deleted. Is there any way for Propel to know that a record has been soft-deleted when you access it, so that a null-refe...

Trying to find the previous six days given any date...

I'm using strtotime just fine for finding the previous week and next week's entries in my database, but what I can't seem to find is how to find the previous six days if the user selects a past date. Here's how I know what today and six days previous are: $today = date("Y-m-d"); $minus6 = date('Y-m-d', strtotime('-6 days')); Now how ...

How do I display/compare a dynamic value of a mysql row in a if statement?

I have a checkboxes on my site that when unchecked, update their row in in the db as unchecked, and if checked,update their row in the db as checked. I am creating an ifstatement that will commence with its command if checked, and not if unchecked. I have echoed the variable and it is holding the proper value (checked or unchecked) but n...

String parsing help

I have a string like the following: $string = " <paragraph>apples are red...</paragraph> <paragraph>john is a boy..</paragraph> <paragraph>this is dummy text......</paragraph> "; I would like to split this string into an array contanining the text found between the <paragraph></paragraph> tags. E.g something like this: $string = " <p...

Array Unique in two dimensional array in PHP

Hi I have an array that looks like this : Array ( [0] => Array ( [x] => 01 [y] => 244 ) [1] => Array ( [x] => 02 [y] => 244 ) [2] => Array ( [x] => 03 [y] => 244 ) [3] => Array ( [x] => 04 [y] => 243 ) [4] => Array ( [x] => 05 [y] => 243 ) [5] => Array ( [x] => 05 [y] => 244 ) [6] => Array ( [x] => 06 [y] => 242 ) [7] => Array ( [x] =>...

How much sanatization does this form input need?

Is $username = $_POST['username']; $sanitizedUsername = strip_tags(stripcslashes($username)); enough to prevent malacious sql injections and other types of attacks. If not what else should I use? P.S. I want to allow users to choose usernames and passwords that contain alphanumeric, space and symbol characters (except those like quo...

RSS-reader in Ajax: Help with code, what's wrong/missing?

Hi! I'm learning Ajax currently, and I use "Sams Teach Yourself Ajax in 10 minutes". I've learnt much, and understand Ajax basically. The book writes code-examples and go through the code bit by bit to explain what each bit does. However. In this code there is something wrong written by the author, and I don't know what.. Here is the co...

PHP wrapper that is API-compatible with PDFlib.

Are there any wrappers to any of the other PDF generating packages for PHP that provide API compatibility with PDFlib? Our company has been generating PDFs from PHP using PDFlib for many years, but have not upgraded since version 5. Now that we are upgrading some servers, we need either upgrade or find a replacement. I'd like to replace...

unexpected T_TRY, expecting T_FUNCTION error message, not sure why ?

I am getting unexpected T_TRY, expecting T_FUNCTION error message and am not sure as too why am getting that, can't we use try and catch block inside class like this: class Processor { protected $dao; protected $fin; try { public function __construct($file) { //Open File for parsing. ...

How to stream megaupload videos using divx?

I have seen some websites stream avi videos from megaupload using divx web player. How would I do this for my site? Are there open source scripts to do this? How would I get started? ...

Unable to execute fetch(PDO::FETCH_ASSOC) and not updating csv file.

// First, prepare the statement, using placeholders $query = "SELECT * FROM tableName"; $stmt = $this->connection->prepare($query); // Execute the statement $stmt->execute(); var_dump($stmt->fetch(PDO::FETCH_ASSOC)); while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { echo "Hi"; // Export every row to a file fputcsv($data, $row); } Is t...

Hotmail rejecting php's email's

My website sends activation mails to new members using the php mail() function. I manage my email accounts using the google mail service (aspmx.googlemail.com). But unfortunately, Hotmail users receive the activation email in their unwanted folder. I did some research and found out about SPF records (I can not use keys since I have limi...