php

Infinite matching of a subexpressions (regular expressions) returns only one match

I have a regular expression like this (much simplified): ^(ab)*$ And am matching against this: abababababababab When I run it through preg_match: preg_match('/$(ab)*$/', 'abababababababab', $matches); print_r($matches); I get this: Array ( [0] => abababababababab [1] => ab ) Wheras I expect this: Array ( [0] => a...

MySQL/PHP processing a query help

Ok, I have two tables that I am joining and doing a select on to get three fields back (timestamp, message, and articleNum). Now, this data is basically a log of when an article was created and modified, I have to write the logic to process those three fields I got back. In order to figure out when an article was created and/or modified ...

WYSIWYG textarea component security

Really my question has more to do with the server-side scrubbing of html that's accepted via the WYSIWYG form component. Right now I'm leaning toward using htmlpurifier.org's library. I'm using php strip_tags() function elsewhere. Anyone have an advice/preferences/recommendations? ...

Correct indentation of HTML and PHP using Vim

I've been using Vim for a while, and I can't get proper HTML indentation working in PHP files. For example, what I want is for each child to be indented one tab more than it's parent, as shown below. <?php if(isset($sports)) { //Do something ?> <div> <label>Uniform Size</label> <ul> <li class="left"><label for="s" class="small">S<...

Call C# Web Service with using PHP

I would like to call C# service with using PHP, anyone know how to do it? Thanks ...

What would be the best way to backup and restore mysql dumps with just php?

I know how you do it from the console, and I know you can execute console commands with php, but would there be a way to recursively dump a database into a file, and then restore it from that file later, just using php? I want it to be able to work on windows and nix servers. I am guessing it would need to loop through the tables and ro...

Zend_Form -> Nicely change setRequired() validate message

Say I create a text element like this: $firstName = new Zend_Form_Element_Text('firstName'); $firstName->setRequired(true); Whats the best way to change the default error message from: Value is empty, but a non-empty value is required to a custom message? I read somewhere that to replace the message, just use addValidator(......

Work-around for PHP5's PDO rowCount MySQL issue

I've recently started work on a new project using PHP5 and want to use their PDO classes for it. The problem is that the MySQL PDO Driver doesn't support rowCount() so there's no way to run a query and then get the number of affected rows, or rows returned, which is a pretty big issue as far as I'm concerned. I was wondering if anyone el...

Problem in value assignment from php to javascript

Dear All I am using JQuery & javascript PHP, My Ajax.php just displays the data ,test.php has assigns the value to javascript function. My Problem is I not able to get the values that assigned by test.php, from getList(data). is Any wrong in my logic ?.What to do to get the values assigned by test.php will be displayed ...

Unique and temporary file names in PHP?

I need to convert some files to PDF and then attach them to an email. I'm using Pear Mail for the email side of it and that's fine (mostly--still working out some issues) but as part of this I need to create temporary files. Now I could use the tempnam() function but it sounds like it creates a file on the filesystem, which isn't what ...

JSon object value from PHP

Dear All I am using Json in php, Now I need to access it from javascript, How to pass json object ,to javascript? <?php $array = array("a"=>"Caucho", "b"=>"Resin", "c"=>"Quercus"); $json = json_encode($array); > Where My.js has showAll(){ alert("Show All Json Objects"); ...

PHP sessions for storing lots of data?

I'm developing a media bookmarking site and am looking for a way to remember whether a user has bookmarked an item (without having to go to the DB every page load to check). I haven't used PHP sessions before, but I'm thinking they would do the trick. Would it make sense to do an initial DB call when the user logs in, grab all the item...

serve postscript file with php script

Hi, I want to give a link to a postscript file, but first I want to make a script that will monitor the downloads of this file. The link has to be 'direct' so I added .ps extension to be interpreted by PHP. In the begining the script opens the text file, writes some information and then I don't know what to do. Basically I have something...

Extension PHP5 does not parse in XAMPP

Hello, I've installed XAMPP Apache server and put my website into htdocs. I've started Apache server. On my website I've got files with extension PHP and with extension PHP5.The difference is that when I type in into browser localhost/file.php - I see a parsed website. But when I type localhost/file.php5 (i have this file on server), t...

Does Ruby support var references like PHP?

In PHP, you can make two variables point to the same data. $a = 'foo'; $b = 'bar'; $a =& $b; echo $a // Outputs: bar echo $b // Outputs: bar What we are trying to do in Ruby is set @app_session to be equal to session[@current_app[:uid]]. So we only have to deal with @app_session in our app, and everything is automatically saved to th...

insert into mysql problem

Hi, I have a table with 2 fields (name, confirm). confirm is of type tinyint because I want to put in 0 or 1 Now I want to put 1 in confirm; is this statement correct? if($row['confirm']==0) { $query = "INSERT INTO opt (confirmed) values('0')"; echo 'The user selected options has confirmed'; } ...

Arbitrary image resizing in PHP

What would be the best way to resize images, which could be of any dimension, to a fixed size, or at least to fit within a fixed size? The images come from random urls that are not in my control, and I must ensure the images do not go out of an area roughly 250px x 300px, or 20% by 50% of a layer. I would think that I would first deter...

insert into mysql problem

i have a field in table opt named confirm of type tinyint. i want to insert value(1) by this statement but it is not working can any one help?? $connect= mysql_connect("localhost","root") or die ("Sorry, Can not connect to database"); mysql_select_db("login") or die (mysql_error()); $user=$_POST['staff']; echo $user; $query="SELECT ...

How do you configure Apache/PHP to accept slashes in query strings?

I have two Apache servers running PHP. One accepts forward-slashes in the query string and passes it along to PHP in the expected way, for example: http://server/index.php?url=http://foo.bar works and in PHP this expression is true: $_REQUEST['url'] == "http://foo.bar" However, in the other Apache server, the same URL results in a ...

is_numeric, intval, ctype__digit.. can you rely on them?

is_numeric, intval, ctype__digit.. can you rely on them? or do i have to use regex? function isNum($str) { return (preg_match("/^[0-9]+$/", $str)); } what do you guys think? am i stupid? ...