I need a regex or a function in PHP that will validate a string to be a good XML element name.
Form w3schools:
XML elements must follow these naming
rules:
Names can contain letters, numbers, and other characters
Names cannot start with a number or punctuation character
Names cannot start with the letters xml (or XML, ...
I am using PHP's magic __set and __get methods to access a private array in a class. Use of the class can include "setting" new properties as well as using existing ones. I want to make sure the property names created or requested (i.e. $myObj->FakeProperty) are valid according to the following rules:
Property names must begin with eit...
For a new CMS i've developed a Pages module that allows me to manage the site's tree structure. Each page is reachable from the url http://www.example.com/pageslug/ where pageslug identifies the page being called.
What I want to achieve now is a route that allows me to route all incoming requests to a single PagesController unless it's ...
Hi, I am getting this error for re-declaring saveorder() however, I don't think I am?!?
Cannot redeclare saveorder() (previously declared in :10) on line 71
8.function saveOrder()
9.{
10. include 'tables.php';
11. $orderId = 0;
12. $shippingCost = 5;
...
68. }
69. echo $orderId;
70. return $orderId;
71. }
...
I need a function that will correctly parse NVP into PHP array. I have been using code provided by paypal but it did not work for when string length was specified next to the name.
Here is what i have so far.
private function parseNVP($nvpstr)
{
$intial=0;
$nvpArray = array();
while(strlen($nvpstr))
{
//postion...
I want to use curl to retrieve a table from an external page. So far my code retrieves all data from the page. I have read that using preg_match or preg_replace is the way to go about it.
This is my code so far:
<?php
$ch = curl_init() or die(curl_error());
curl_setopt($ch, CURLOPT_URL,"http://www.megaupload.com/?d=XE30L1GA&w=631&a...
Hello!
Does anyone know of a class/library/etc. that can simulate 32 bit unsigned integers on a 32 bit platform in PHP?
I'm porting a C lib into PHP and it uses a lot of integers that are greater than the maximum for 32 bit signed int.
...
The clever folks at Caucho are quick to point out that Quercus is 3x-5x faster than straight mod_php (without APC). But digging deeper in the documentation, you'll see that the PHP-to-bytecode compilation is only available in Resin Pro ($699).
What I'd like to know is, how fast (i.e. how slow) is Resin Open Source for executing PHP code...
Hi,
I've got PHP and HTML code stored in a database table. When I get this data, I need to echo the HTML and process the PHP. I thought I could use eval() for this, which works, if I do this eval("echo 'dlsj'; ?> EVALED "); I get dlsjEVALED printed out.
The problem is, I get a fatal error when I run longer scripts. Things like:
Parse e...
I have a unix timestamp for the current time. I want to get the unix timestamp for the start of the next day.
$current_timestamp = time();
$allowable_start_date = strtotime('+1 day', $current_timestamp);
As I am doing it now, I am simply adding 1 whole entire day to the unix timestamp, when instead I would like to figure out how many ...
Hi,
I'm trying to install zorba php extension on windows and I am having all sorts of problems. I have installed the zorba binaries on my computer, but when I try to install the PECL package (pecl install zorba-alpha) I get the following error "ERROR: the DSP zorba.dsp does not exist".
I've tried searching for zorba_api.dll or zorba_ap...
I just wanted to know what are some basic PHP security techniques I should use when creating a web page that accepts articles?
I'm fairly new to PHP and was wondering what will hold the fort down until I'm a security expert?
...
I want all CSV files in a directory, so I use
glob('my/dir/*.CSV')
This however doesn't find files with a lowercase CSV extension.
I could use
glob('my/dir/*.{CSV,csv}', GLOB_BRACE);
But is there a way to allow all mixed case versions? Or is this just a limitation of glob() ?
...
I found the regular expression for MM/DD/YYYY at http://www.regular-expressions.info/regexbuddy/datemmddyyyy.html but I don't think I am using it correctly.
Here's my code:
$date_regex = '(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d';
$test_date = '03/22/2010';
if(preg_match($date_regex, $test_date)) {
echo 'this d...
I have this php code from my login.php
if (isset($_POST['logIn'])) {
$errmsg = "";
$logname = mysqli_real_escape_string($dbc, trim($_POST['usernameIn']));
$logpassword = mysqli_real_escape_string($dbc, trim($_POST['passwordIn']));
$query = "SELECT user_id, username FROM members WHERE username = '$logname' AND password =...
Hi all,
I am having a mental blank here and cannot for the life of me figure out a solution.
My scenario is that I am programming in PHP and MySQL. I have a database table returning the results for a specific orderid. The query can return a maximum of 4 rows per order and a minimum of 1 row.
Here is an image of how I want to return th...
This is a topic that, as a beginner to PHP and programming, sort of perplexes me. I'm building a stockmarket website and want users to add their own stocks. I can clearly see the benefit of having each stock be a class instance with all the methods of a class. What I am stumped on is the best way to give that instance a name when I ins...
Is there a way to take any number, from say, 1 to 40000 and generate an 8 character hash?
I was thinking of using base_convert but couldn't figure out a way to force it to be an 8 character hash.
Any help would be appreciated! Thanks.
...
So, lets say I have a record:
$record = new Record();
and lets say I assign some data to that record:
$record->setName("SomeBobJoePerson");
How do I get that into the database. Do I.....
A) Have the module do it.
class Record{
public function __construct(DatabaseConnection $database)
{
$this->database = $database;...
When I first meet PHP, I'm amazed by the idea Sharing-Nothing-Architecture. I once in a project whose scalaiblity suffers from sharing data among different HTTP requests.
However, as I proceed my PHP learning. I found that PHP has sessions. This looks conflict with the idea of sharing nothing.
So, PHP session is just invented to make...