php

My simple PHP function for maintaining values in my form isn't working. Really newbie!

Here's my code: <html> <head> <?php function getValue($field){ if(isset($_GET[$field])){ return $_GET[$field]; } else{ return ""; } } ?> </head> <body> <form action="class2.php" method="get"> <dl> <dt>First Name:</dt> <dd><input...

HTTP Base SQLAlchemy database

Hi all. I have a little problem, I want to use SQLAlchemy (Elixr to be exact) to do some task on a RDBMS MySql on a web server I have in hosting. My Hosting provider does not allowe me to connect to MySql directly, just by php scripts... I was think to use a simple php script to tunnel the queies done by SQLAlchemy. There is some way to...

HTTP_HOST vs. SERVER_NAME

When would you consider using one over the other and why? ...

PHP MySQL - Storing Configuration Then Reffering To The Config By Date

I'm building an Insurance Site, and will be selling policies online. I'm designing the database at the minute and need some advice on the best way to store the rates I'm using to calculate the premium. There's a clever way of selecting the rates, based on the date the policy was purchased - from a rates table, using like an 'effective ...

How to efficiently sql query child records from multiple tables?

We have a simple database. The User table holds users. The Accounts table holds multiple accounts for each user. The Topics table holds multiple topics for each account. So, a user would have multiple accounts and each account would have multiple topics. So, if I have a user with id=1 how do I efficiently query all 3 tables to get all t...

Where would I run this validateForm method? I'm a very newbie PHP developer getting the hang of web developing.

Here's what I have: <html> <head> <?php $validForm = false; function getValue($field){ if(isset($_GET[$field])){ return $_GET[$field]; } else{ return ""; } } function validateForm(){ //magic goes here. } ?> </head> <body> <?php if(...

where to put & in php?

i wonder where i should put the & properly. $b =& $a; or $b = &$a; ...

in PHP, how do I create an array of all strings between two strings?

I have a chunk of text like: <b>First content</b> followed by <b>second content</b> OR "First content" and then "second content" And I want to create an array that looks: [1] => "First content" [2] => "second content" From either example, where I get the content between two tags. I've figured out how to get the first instances, bu...

what does & mean in this case?

i know that its creating a reference in other cases. but what happens here? $crawler = &new MyCrawler(); ...

MAMP Config help, display PHP errors

I am running the latest version of MAMP on Snow Leopard. My php.ini file has been configured to display errors. display_errors = on. The phpinfo(); page displays the status of error reporting, it is on. I have restarted my web server several times. I've searched through Google, and I cannot find any similar problem. Everyone just says...

wordpress permalink post_type

i am looking for a way to get the post_type into a wordpress permalink structure - especially considering custom post_type's defined by my own plugin. is there an easy way to do that, or do you know any decent documents about wordpress url handling / redirection (codex seems to lack a bit on the rewriting side of things). ...

How to implement the Countable interface in PHP?

So that count($object) will return the number of records in it ...

cURL multi hanging/ignoring timeout.

I'm using a 'rolling' cURL multi implementation (like this SO post, based on this cURL code). It works fine to process thousands of URLs using up to 100 requests at the same time, with 5 instances of the script running as daemons (yeah, I know, this should be written in C or something). Here's the problem: after processing ~200,000 urls...

tenjin template and javascript output

what is the best way to read a tenjin template with javascript object in it? i am using tenjin template for my PHP based website and i wanted to read a flash/swfobject that is output from tenjin.. has anyone encountered the same issue? ...

PHP: include file relative to calling file NOT root file?

OK say I have a file called fileA.php in the same directory I have another file called fileB.php so inside fileA there is this require_once('fileB.php') notice I did not specify a file path because both files are in the same directory. Now if fileA is included into another file that is located somewhere else, it fails to include fileB ...

How can I prevent my form being sent if a user writes misformated entries in my fields? ie. Letters in number fields.

What happens: When I write two values in both text boxes, the page doesn't show the Congratulations message as it should. When I write only 1 value, the correct thing happens, which is not show the congratulations message. What should happen: If a user writes only 1 value, the form should still appear with any previously filled...

What's the default inheritant type of a member function in PHP?

class foo implements Countable { function count() { # do stuff here } } What's the type of count,public,protect or private? ...

How to implement the Iterator interface in PHP?

Please explain with a tiny demo ...

PHP Session Variables

A user will click on a link which will open a new page (code below). My problem is that when this new page is opened, it creates a NEW session ID. How do I stop this from happening? require_once('../../config.php'); //Database connection details require_once('../../connect.php'); //Connect to database session_start(); <--------...

PHP - Getting position within a loop

Hi, I have a function which is called within a foreach loop and takes in two parameters, an integer, representing the number of times the loop has run and an array (of no fixed size). I would like to return the value of the array key that is equal to the counter. For example, if the array has four elements: A, B, C and D and the counte...