php

Undefined variable after using require_once

I have created a Page class and all the pages on my website are objects of that Page class. Each Page object has a title attribute which is passed in as an argument to the constructor and so creating a new Page object looks as follows. <?php require_once('library/Page.php'); $page = new Page('About'); $page->header(); This is where...

Extract Address from String in PHP with RegEx

My Problem I'm attempting to crawl the individual links on the US House of Representatives Site to find Washington addresses for all of the listed individuals. The problem is that the format of the Washington address varies from time to time. Sometimes there are bullets, pipes, new lines and break-tags making it difficult to match. I...

PHP myAdmin - Change Field Order (Move Up Or Down)

How do I change the order of my table fields without deleting the field and re-inserting it, using PHP myAdmin? ...

Why isn't CodeIgniter passing variables?

What should be happening: user navigates to URI, routes.php grabs the State and sends it to the controller, the controller returns some info from a database query. Pretty basic stuff. The problem: the URI isn't passing the variable to the controller. I'm being told Missing argument 1 for States::state_summary I can set a default f...

PHP explode is removing the first array value

Ok, first off, I applogize if this question has been asked before, I've spent the last 12 hours sifting through hundreds of forum threads and haven't found one that answers this question exactly yet so here goes. I have a page that I built that has a userlist that is autopopulated as users log in, and each users has a checkbox that allo...

Adding custom class to every widgets in wordpress, what's your approach?

Hi, I'm creating a theme for wordpress and I am having problem implementing image replacement on headers on my widgets. How do you I add a custom class or id to wrap my widgets? for example HTML: <div id="sidebar"> <div id="customWidgetId"> <h2>This Title will be replace by an Image</h2> <p>Wordpress 'Text' Widget cont...

How to generate polygonal thumbs?

Is there's a way to generate polygonal thumbnails in PHP? (ImageMagick, GD, etc) Here is an example of what I want to achieve: http://www.area105.com/gallery/shme/thumb1.png ...

alert message when database updated

I am creating a Chat application in php. AIM: when a user1 invites user2, user2 want to get a alert or popup message that user1 has invites him. What i have done is - When user1 invites, the message is stored in database. In user side i used to check whether Database is updated or not. If database is update i used to show alert. Thi...

What is wrong with this statement echo '<option value='+$index+'>'+$county[$index];?

echo '<option value='+$index+'>'+$county[$index]; It is PHP code. It doesn't output what I want. Any idea? ...

Not run some tests in PHPUnit?

Hi, I don't want to run all the tests sometimes to save time. I know I can comment the tests. But this method isn't elegant. I'm wondering whether there is some simple way to do that. All advice is appreciated. Thanks for your time and best regards, Box He ...

How to avoid duplicate when a user click the "refresh" button of his browser?

For example, I ask this question and click "Post your question" and stay in the current page. Now I may click the "refresh" button of my browser to see new answers. But I find that on my website, if I click the "refresh" button, a duplicated question will be published. How to avoid this problem? I am using PHP. ...

Importance of backtick around table name in MySQL query

In MySQL queries, how important is it to put backticks around a table name. Does it have something to do with security? Are MySQL injection attacks possible through the table name if the table name is created dynamically in PHP based on user inputs? ...

Joining Arrays in PHP

This is really simple but I need a quick way to do this. I have three arrays like $a = array('a','b','c'); $p = array('p','q','r'); $x = array('x','y','z'); How do I combine them to make array ( [0] => array ('a','p','x'); [1] => array ('b','q','y'); [2] => array ('c','r','z'); ); ...

How to save information in inputs inside a form so it doesn't disappear when form is submitted to itself ?

I have a picture upload inside a form... The file is a php file btw... Problem is whenever this form is filled in, and the user clicks to upload the first picture, the form is submitted to itself and all the fields which the user may have filled in will go blank... I know of one way to do it, alot of 'isset' in my php code, but is the...

PHP and unit testing assertions with decimals

I have a method that returns a float like 1.234567890.I want to test that it really does so. However, it seems that this returned float has different precision on different platforms so how do I assert that the returned value is 1.23456789? If I just do: $this->assertEqual(1.23456789, $float); Then that might fail on some platforms wh...

Ajax-driven complex layout RIAs and mvc frameworks

Hi! I need to combine a ajax-driven RIA frontend, using for example JQuery layout plugin (http://layout.jquery-dev.net/demos/complex.html) or ExtJs (http://www.extjs.com/deploy/dev/examples/layout/complex.html), with... a php mvc backend, using for example Zend MVC, CodeIgniter or Kohana Where can I find info on how to set up the a...

php read start from zero number case

Hi All, May you can help me... many years ago my friend gave me php script code presented below, now i want to change it can read numbering start from zero existing just possible read 1:1, 10:200 etc.. but i want to make also possible read from 01:01, 0000002:0120 etc... function is_valid_number($sesuatu) { if(preg_match("/^([0-9]+)$...

Catching Exceptions Syntax Error in PHP

I'm trying to use exceptions in PHP as a way of avoiding multiple if-then-else blocks. However, when I try to catch the exception, I get the error Parse error: syntax error, unexpected T_CATCH in /directory/functions.php on line 66. Am I doing something wrong with my throwing and catching? function doThis($sSchool, $sDivision, $sClass, ...

"Forging" (= mocking) an AMFPHP remoting request

I am using AMFPHP with great success to link my database with my Flex application. However I want to be able to test the remoting requests outside of flash, by typing something like: http://localhost/amfphp/gateway.php?%5BWHAT DO I PUT HERE] What do I put after the questionmark in order to have the browser (or a C++ http component) ca...

Prevent tidy from adding html tags

I have a class that generates some html (form elements and table elements), but this class returns all the html in one line. So I am trying to use tidy to beutify the code (indent the code, put line breaks, etc), the only problem I am having is that's also generating the tags I don't want. Here is the code: tidy_parse_string( ...