php

php replace regular expression

I need to use php to add a space between a period and the next word/letter when there's none. For example, "This is a sentence.This is the next one." needs to become "This is a sentence. This is the next one." Notice the added space after the first period. My problem is that even if I'm able to make a regular expression that finds ever...

security token problem with ajax requests

when building apps I use a token to prevent attacks on the forms each time a form is rendered it gets a new ONE TIME security token that i include in the form as a hidden field. this token is also stored in the session. when the form is sent, the token is verified against the token in the session to make sure the form is legit. This w...

How do I convert a string the looks like a hex number to an actual hex number in php?

Hey everyone, I have a string that looks like this "7a" and I want to convert it to the hex number 7A. I have tried using pack and unpack but that is giving me the hex representation for each individual character. I'm out of ideas and don't know where to go from here. Thanks for the help! ...

Session variables survives after logout

Hi guys! I have a problem, will explain how to reproduce the problem: 1- login into my page (sesion variables set as $_SESSION['logged'] = true and $_SESSION['id'] = 123 2-then inside the main menu I click logout option, code like this function logout() { session_start(); $_SESSION['id'] = null; $_SESSION['logged'] = nu...

Firefox jQuery Drag and Drop File Upload together with PHP

Hi, Hoping to get some assistance but I am after a jQuery/PHP means of allowing a user to drag and drop files and then via PHP, upload one or more files to a specific directory on a Linux box. I only have Firefox 3.6 as my base browser but can also move to FFox if need be. Cann use any HTML5 features as long as I'm using Firefox 3.6 ...

PHP: Display comma after each element except the last. Using 'for' statement and no 'implode/explode'

I have this simple for loop to echo an array: for ($i = 0; $i < count($director); $i++) { echo '<a href="person.php?id='.$director[$i]["id"].'">'.$director[$i]["name"].'</a>'; } The problem here is that when more than one element is in the array then I get everything echoed without any space between. I want to separate each element...

PHP OOP properity constant usage

Hi there. I'm really new to OOP. I'm even not a newbie - I'm noob. So. I want to transfer my pseudo-CMS from "normal" programming, into OOP programming system. And so: private static $dsn = DB_TYPE.':host='.DB_HOST.';dbname='.DB_NAME; What here causes problem? Usage of constraints? I don't know. My editor (aptana studio) shows error ...

How can I detach/ignore a single behavior in Doctrine?

My question is very close to this one http://stackoverflow.com/questions/1471986/how-do-i-detach-a-behavior-in-symfony-doctrine I have a model with several behaviors, one of which I need to ignore for a single query. I have a UserModel with attached behaviors for SoftDelete Deactivatable (custom) Timestampable In a very specific ca...

How to tell if ob_gzhandler is working?

How can I check to see if ob_start("ob_gzhandler"); is working and test the difference with or without it? Thanks, ...

When the target of a .NET HttpModule RewritePath call is a PHP file the $_POST array is empty

Hello friends. We have an application running on IIS 6 which uses a custom HttpModule to rewrite urls. This works great (well done us) except in the case where the Context.RewritePath destination is a .php file. The php file is executed as expected, however the $_POST collection is empty meaning it cannot access any forms which are subm...

How to debug php webapp in eclipse?

I want to give the URL on my localhost, set POST variables and debug it and go... How to do this? ...

PHPMailer with GMail: SMTP Error

Hello all, I am making use of PHPMailer to send mail through GMail. The code I use is straight from a tutorial and it works perfectly on my laptop. However, testing this on a Windows 2003 Server - it seems to always return an SMPT error: SMTP Error: Could not connect to SMTP host. Mailer Error: SMTP Error: Could not connect to S...

How to set up a database and API web page to accept POST updates from iPhone?

Hi there, I am developing an iPhone app, which now can update Twitter account with GPS coordinates in real-time, by the Twitter API link: http://username:[email protected]/statuses/update.xml , and I am looking at how to make my own database to accept updates from iPhone, via a similar API page. It seems a .php page can serve as the...

How to output image via php from another domain

Image tag inside email message: <img src="http://www.mydomain.com/image.php?lastest=1"&gt; Part of image.php script: case 'image/gif': header('Content-type: image/gif');$img=@imagecreatefromgif($image['src']);if($img) {imagegif($img);imagedestroy($img);} break; But how i can do the same with this image? http://www.anotherdomain.c...

How do I turn off such PHP 5.3 Notices ?

Notice: Constant DIR_FS_CATALOG already defined I've already commented out display_errors in php.ini,but is not working. How do I make PHP not output such things to browsers? UPDATE I put display_errors = Off there but it's still reporting such notices, is this an issue with PHP5.3? Reporting numerous Call Stack too.. ...

seperated mysql statement query in php

So, I can run the following statements from within mysql itself successfully. SET @fname = 'point1'; SELECT * FROM country WHERE name=@fname;` But when I try to pass the query through php like this and run it, I get an error on the second line $query = "SET @fname = 'point1';"; $query .= "SELECT * FROM country WHERE name=@fname;";...

Debugging PHP in Aptana 2.0

I'm a real newbie when it comes to PHP debugging so forgive my stupidity. I have a simple html form that submits to a PHP script and I want to debug that script and see what's being sent from the form. My Aptana has two two PHP interpreters installed; Zend Debugger on port 10001 and XDebug on 9000 I have the Firefox Aptana Addon instal...

Regular expression to remove second couple of parenthesis (only when available)

Hi, I have something like this: $arr[] = 'Seto Hakashima' $arr[] = 'Anna (segment "Yvan Attal") (as Robin Wright Penn)' $arr[] = 'Sara (segment "Yvan Attal")' I need to remove the the second couple of parenthesis (only when there is a second couple), and get this: $arr[] = 'Seto Hakashima' $arr[] = 'Anna (segment "Yvan Attal")' $arr[...

russian characters not accepted in php / phpmyadmin ?

I have a website in 3 languages: english, dutch and russian. There's a little CMS where the user can update the text on the website. everything works good, except for the russian text.. If I enter any russian text in the form in the CMS, I get "????" in the phpmyadmin database and on the website. I am completely new to charsets, it's ...

PHP: Remove all fcn not acting as expected, Code Inside

I made this simple function (remove all $elem from $array): function remall($array, $elem) { for($i=0; $i < count($array); $i++) if($array[$i] == $elem) unset($array[$i]); $newarray = array_values($array); return $newarray; } But it isn't working perfectly, here are some inputs and outputs $u = array(1...