php

Drupal 6: Only inserting first character of value to MySQL

I am working with a hook_form_alter on a CCK type (for you drupal-ers). I have a field that is normally a select list in my node form. However, in this instance, I want to hide the select list, and populate its value in the form with an SQL query. Everything was going nicely. I could see that my desired value was showing up in the HTML...

Web form generator PHP class - empty property on foreach

I am currently building PHP class that generates web form for flexibility and localization issues. I am having difficulty assigning a key and value for dropdown input; for some reason the foreach seems does not get array variable ($country_list). Here is my code that I am having difficulty. require_once('_include/country_list.php'); //...

How do I text-align:center php echo text in Firefox?

I don't see this question answered anywhere else here. Here's the code: <div class="copyright"> <h2 class="copyright unselectable" onselectstart="return false"> &copy;&nbsp;2009&nbsp;-&nbsp;<?=date("Y") ?>&nbsp;<?=PROJECT_NAME?> </h2> </div> It's aligning right in IE but not FF or Safari. It seems to not be taking into account the s...

Symfony Deprecated Function

Hey All, I have been using symfony for a few weeks now and I am using the online help a lot but the "Definite Guide To Symfony" seems to be very outdated. For example, I want to use the form helper function like the select_tag() function or the ajax form_remote_tag() function. However, these dont seem to exist anymore and I can only fin...

paypal IPN works but stuck at paypal's thank you page!

my paypal ipn php works correctl. i tested it out with sandbox account, and the payment works, my database is updated properly etc. however, I expected the page to redirect back to my shopping site. instead it just sits at paypal's Thank You For your Payment page. how can i make it redirect back to my shopping site ? ...

implementing a simple prepared query in PHP

I'm trying to create a very simple database abstraction, one part of it using prepared queries. Now, I have a function take a query string and an array of values like this: $query = "SELECT `first_name`, `last_name` FROM ::table_name WHERE `id` = :id" $values = array( 'table_name' = $this->table_name, 'id' = $user_id, ); this...

Design Question: Which is Better practice?

Hello, I have 3 different web servers which handle user data (username/passwd/email/etc.). I have 3 different web service calls respectively, so I've created 3 different classes which calls for the same information (getUsername, setUsername, getEmail, setEmail, etc.). From the main class I instantiate each webservice-call objects and whe...

Conditional configuration: How to detect if I'm local or online?

I want to provide different configurations for local and offline. At the moment, every time I upload my stuff to the web server, I must make sure that I don't mess up with the different config files. One for local development, and one for online. I slightly remember a couple of years ago, a code snippet distinguished somehow automatical...

Reading Foxpro database date field using PHP

I've wrote a PHP script to export a Foxpro database to other formats by using ADODB (http://phplens.com/lens/adodb) library to access Foxpro OLE DB provider. Everything worked fine except the date fields are mangled and become like these: 11/17-/2-00 3/4/-20-08 By comparing to actual data I can guess that it is probably in the forma...

Symfony Javascript Form Validation

Hey, So I have a form on my website that will submit a name and email address. I want to submit them with ajax which is simple to do, but I wanted to verify that both fields are filled in and that the email is in the correct email form. Basically I want to run some client side validation on the fields before submitting it via ajax. Do...

Putting checkbox data into textbox

Is there a way to take multiple check boxes and have the related id/name automatically populate in an un-editable text box/text field? As per one of the suggestions...I am expanding and clarifying. I have several checkboxes that I want saved into the SAME db field...at the same time. So, since I'm a novice programmer where php/sql (...

why is OOP hard for me?

I have trouble writing OOP in PHP... I understand the concept but I never create classes for my projects... mainly because it's often a small project and nothing complex. But when I read OOP, it seems more difficult to code than writing simple procedural statements. It also seems to take a lot of room as well with so many empty abstract ...

Mysql query returns only the first letter of strings

Can someone please tell me what I am missing. the following sql query returns only the first letter of strings it fetched from the my database: $result = mysql_query("SELECT * FROM users) or die("error in the query"); thanks. Update $result = mysql_query("SELECT * FROM properties ...

PHP curl question

Why does this code hang? Comment out the break statement and it works fine, but only for the first item in the $sitelist array. I know about PHP curl's multisite feature, but I am not interested in fetching files in parallel. Code snippet: $sitelist = array(11204,11509,20602,21601,22003,22704,23106,23303,23402,23422,23427,30215,30220...

PHP content caching for javascript and css

I have a unique problem, which is proving difficult to solve using google. I am consolidating all of my javascript and css into separate php files, which use require_once() to pull the contents of the files in. The javascript file looks something like this: <?php header('Content-Type: text/javascript'); require_once('jquery.form.js'); r...

How to brush up on PHP?

I have an interview on Tuesday for a PHP job. I've been programming in PHP for about 6 years, but mostly ad-hoc self-built systems, it wasn't until about a year ago that I started to adopt frameworks and get more OOPy. These are familiar concepts from other languages though. What can I do to brush up and ace my interview? ...

Strange class behaviour; Gets applied to drop list option when it shouldn't...

This is kindof hard to explain... I have this class: .nav_option_main { background-color: #FC9; } I have two drop-lists, let's call them Drp1 and Drp2. Drp2 is populated depending on Drp1:s value, using javascript. Some values in Drp2 has the above class applied to them, but only some. Now, here is the strange problem, lets say...

2D Rotation Array

I need help converting this code from this thread: http://stackoverflow.com/questions/646468/how-to-rotate-a-2d-array-of-integers to PHP arrays. int [,] newArray = new int[4,4]; for (int i=3;i>=0;--i) { for (int j=0;j<4;++j) { newArray[j,3-i] = array[i,j]; } } Also, will this code work if the blocks are off-center? ...

Email Validation: converting a regular expression written in PHP (preg) to .NET (Regex)

Based on this answer... http://stackoverflow.com/questions/201323/what-is-the-best-regular-expression-for-validating-email-addresses/201378#201378 Which led me to this site... http://fightingforalostcause.net/misc/2006/compare-email-regex.php I'd like to use this regex for email validation for my ASP.NET MVC app: /^[-_a-z0-9\'+*$^&%=~...

Math average with php

Time to test your math skills... I'm using php to find the average of $num1, $num2, $num3 and so on; upto an unset amount of numbers. It then saves that average to a database. Next time the php script is called a new number is added to the mix. Is there a math (most likely algebra) equation that I can use to find the average of the o...