php

How to make sure no scripts except those under my own domain, can include the db connection file?

I would like to ensure that any scripts that are trying to "include" my database connection file are located under my own domain. I don't want a hacker to include the database connection file to their malicious script and gain access to my database that way. My connection file's name is pretty easy to guess, it's called "connect.php". So...

PHP form processing - how to capture text from field that has variable Name/ID

I have a form that has a field pulled from the database as a dropdown. I need to get the text selected in the dropdown but I don't know in advance what the field ID will be. This is basically just a form that has already been generated. I don't need to pull anything from the database, it's already on this page. All I need to do is get t...

PHP fastest method of reading server response

Hi there, im having some real problems with the lag produced by using fgets to grab the server's response to some batch database calls im making. Im sending through a batch of say, 10,000 calls and ive tracked the lag down to fgets causing the hold up in the speed of my application as the response for each call needs to be grabbed. I ...

Magento "File was not uploaded"

I'm currently using the magento admin interface, trying to upload an image in the "manage products" and I get the error "file was not uploaded" after I browse the file and click "upload file". I've looked on other forums and the main solution I saw were to make sure that php.ini has the following lines... magic_quotes_gpc = off short_o...

How do I create substrings from an array using PHP?

I have an array of data that looks like this: 2008, Honda, Accord, Used, Car And I'm trying to figure a way to make a number of sub strings from each item in the array. For example, I would like to loop each item and create the following substrings: 2008 2008 Honda 2008 Accord 2008 Used 2008 Car 2008 Honda Accord 2008 Honda Used 200...

How does this RegEx for parsing emails work in PHP?

Okay, I have the following PHP code to extract an email address of the following two forms: Random Stranger <[email protected]> [email protected] Here is the PHP code: // The first example $sender = "Random Stranger <[email protected]>"; $pattern = '/([\w_-]*@[\w-\.]*)|.*<([\w_-]*@[\w-\.]*)>/'; preg_match($pattern,$sender,$matches,PRE...

PHPUnit installed but class PHPUnit_TestCase not found

Talk about falling at the first hurdle. My test script: <?php require_once('PHPUnit/Framework.php'); class TransferResponseTest extends PHPUnit_TestCase { ... } Running my test case: $ phpunit TransferResponseTest Fatal error: Class 'PHPUnit_TestCase' not found in /Volumes/Data/greg/code/syndicate/tests/TransferResponseTest...

PHP - Convert to date format dd/mm/yyyy

Hi there! I have the following date: 2010-04-19 18:31:27. I would like to convert this date to the dd/mm/yyyy format. Can anyone give me some help? Thanks in advance for the help, Best regards! ...

hudson+git FATAL: Could not apply tag

I'm trying to set up hudson with git according to this article, but I still get git errors during build: FATAL: Could not apply tag-PROJECTNAME-ID ... Caused by: hudson.plugins.git.GitException: Command returned status code 128: *** Please tell me who you are. running: git config --global user.name shows valid data, .gitconfig is ac...

PHP - How to make/generate a graph image depending on values in a database?

Hello. How could I make an image graph from values in a database? The idea came from "Steam", which uses a graph to show how many users are online. How could I do the same thing? It seems like the graph is one whole image; not made up of parts. Here's an image of the graph from Steam: Thanks. ...

Doctrine Many to Many

Hello, I have a question about Doctrine ORM M:M. I built some tables like this: -User +id +name -Group +id +name I want to link these table via a new table with Doctrine: In Group class: $this->hasMany('User as Users', array( // I'm wondering what I can fill here 'refClass' => 'UserGroup' )); and in th...

iterate through fb:random

does anyone know how i would fill data from mysql database in fb:random and iterate through it, to pick a random quote? fb:random $facebook->api_client->fbml_setRefHandle('quotes', '<fb:random> <fb:random-option>Quote 1</fb:random-option> <fb:random-option>Quote 2</fb:random-option> </fb:random>'); mysql data: $rowcount = mysql_resu...

Why would some POST data go missing when using Uploadify?

I have been using Uploadify in my PHP application for the last couple months, and I've been trying to track down an elusive bug. I receive emails when fatal errors occur, and they provide me a good amount of details. I've received dozens of them. I have not, however, been able to reproduce the problem myself. Some users (like myself) exp...

Consequences in PHP of implementing an interface through two different routes?

What are the consequences of implementing the same interface through two different routes in PHP, are there any? What I mean, is something like this: interface baseInterface {} abstract class baseClass implements baseInterface { } interface myInterface extends baseInterface {} class myClass extends baseClass implements myInterface {...

occurance of string

i know you can find the first and last occurrence in a string using strstr() and strchr but how do i find the second occurrence, and the third occurrence of needle inside haystack? im using this to find the last occurrence of needle and the first occurrence of another needle and their position, then return the string that is in between e...

CakePHP - Order in $hasMany model being ignored

I have one model that has a $hasMany attribute. If I just have the following: var $hasMany = 'OtherModel' and in the class OtherModel extends AppModel I have the following: var $order = 'colour_id DESC'; The order is ignored, but if I have this in the first model: var $hasMany = array( 'OtherModel' => array( ...

mysql_real_escape_string on all mySQL queries?

Is mysql_real_escape_string supposed to replace both addslashes() and stripslashes()?? ie.. do I use it to encode form input variables on MySQL inserts as well as use it in place of stripslashes on MySQL select statements? Sincerely, Confused PHP noob ...

Problem after adding <form>?

When i added <form> to my web page, all my javascript stopped working, and when i put the form at the begining of my table submit wont work, what i am doing wrong. below is my code after testing on other browser it works fine but on Firefox it doesn't Update: After checking on firefox java error console it appears that Checking Function...

What is the most recommended resource to learn PHP extensions?

I need to learn how to develop PHP extensions. So, I assume I have to refresh my CPP skills (or is it C?). What IDE should I use (auto-completion, object browsers etc). I plan to develop on Ubuntu 32. Is there a good book or good website I can learn from? ...

TYPO3: Use TCA.php to build Frontend Forms?

Hi! I'm searching for a solution, to build a frontend form from the TCA.php of my TYPO3 extension. Is there any way, to select TCA.php values, from my extension Class? I want to build a select-element with values of the TCA.php file. Would be amazing, if someone could give me some advice :) ...