php

What does sprintf stand for?

Hi everyone, I tried looking it up on google and wikipedia but couldn't find an answer... Does anyone know what 'sprintf' or 'printf' stands for? Is it an abbreviation for something??? Thanks ...

CakePHP cannot modify header?

I am using CakePHP 1.3 and it keeps telling me the following. Cannot modify header information This ONLY happens when I include the Auth component. var $components = array('Auth'); Am I doing something wrong, a bug, or what? ...

PHP forking php-fpm with pcntl_fork()

I'm forking with this code: echo "1. posix_getpid()=".posix_getpid().", posix_getppid()=".posix_getppid()."\n"; $pid = pcntl_fork(); var_dump($pid); if ($pid == -1) die("could not fork"); if ($pid) { //parent echo "2. pid=".$pid.", posix_getpid()=".posix_getpid().", posix_getppid()=".posix_getppid()."\n"; } else { //child $sid = posix...

[PHP] PHP fails with no error

Hi all. I am building a template parser. The template parser works like this: Tokenize (make for each part of the template code a token) Parse Use my ParserHelper class. You can add rules for this system, and then it checks the token list for a valid grammar. Add / change some tokens for extra functionality Compile (translate to php ...

Find matching brackets using regular expression in PHP

Assuming I have this string: "abc{def{ghi{jkl}mno{pqr}st}uvw}xyz" and I want to match this: "{def{ghi{jkl}mno{pqr}st}uvw}" what should my regular expression look like..? In other words, the match should start with "{" and end with "}", but it must have as many {'s as }'s in between. ...

Pull first X words (not just characters) from mySQL

I'd like to be able to pull the first X words from a database field for use in a preview. Basically if a field 's content was "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris malesuada." I would like to echo "Lorem ipsum dolor sit amet... see more" What's the best way to do this? The only thing I know to do is p...

PHP Post Request inside a POST Request

There is a contact form which current action is "http://www.siteA.com/ContactInfo.php", it sends fields and values. In ContactInfo.php, i just catch the values and send and email to [email protected] BUT, inside ContactInfo.php, I need to send the same data to another destination, in other domain http://wwws.SiteB.com/Reg.aspx I have tryed out to...

How to do a parameterized query

[ Status: Learner ] I am attempting to implement a parameterized query but I am having problems. Jonathan Sampson recently hinted at how this could be done (#2286115), but I'm not following his suggestion correctly. Here is my script $cGrade = "grade" ; include_once ( "db_login.php" ) ; $sql = "SELECT last_name AS last_name ...

Evaluate page & store in variable?

I want to grab a php file, evaluate any php, then store the contents in a variable. We'll call this.. page.php <?php $content = "Hello World."; ?> <html> <head> <title><?php echo $content ?></title> </head> <body> <?php echo $content ?> </body> </html And I want to put that into a variable by calling a function from another file. ...

help with regular expression

i dont undestand the () in regexp. eg. what is the difference between these lines: "/hello/" "/(hello)/" ...

How can I limit the total number of SimpleXML results?

I'm looking to limit to the first 5 results returned here. This works, but it does not limit the data set: <?php foreach($sxml->status as $status){ $name = $status->user->name; $image =$status->user->profile_image_url; $update =$status->text; $url = "http://twitter.com/" .$status->user->screen_name; echo "<li><a href=\"" . $url . "\"...

Encrypt nsdata in iphone and decrypt it in php

Hi All, I am new to Iphone development , I want to create an application in which I have to upload some data on php server using my Iphone application. For this I have an file on the Iphone whose content I have to upload on php server. For this I have converted the content of the file in NSData and now I want to encrypt this nsdata obje...

error in backing up mysql database through php

What's wrong with this code?I'm currently calling the code below using a link. Is there anything else needed for this to work? The error is specifically in this line: $backupdir = 'C:\wampbackup\x.sql'; What might be a possible solution to this. I'm a beginner so please bear with my lack of knowledge. $host= 'localhost'...

complex math with great circle formula

I have a from location (latitude, longitude) and to location (latitude, longitude). After calculating, it should show me what would be the nearest way to go from using a compass. The following is PHP code to do that, but its showing the wrong direction, I need little help on this. function GreatCircleDirection ($OrigLat, $DestLat, $Orig...

What's the best compression to use with uploading big catalog by FTP ?

If you are uploading something like Zend Framework using poor internet conneciton it may be problematic. I think the compression of the catalog is the best solution. But what compression system is the best for this task ? We are using PHP, of course. I have some ideas like PHP + exec + unrar and http://www.php.net/manual/en/refs.compre...

help with reg_replace()

i want to get the word Asarum in the below line: <A HREF="http://www.getty.edu/vow/TGNFullDisplay?find=&amp;place=&amp;nation=&amp;english=Y&amp;subjectid=1062783"&gt;Asarum&lt;/A&gt; i tried with: preg_replace('/<a.*?>/i', '', $link); preg_replace('/<\/a>/i', '', $link); echo $link; but it doesn't work. nothing was cut out. coul...

How to make something to let the user change the language in a multilingual website that uses php arrays?

I followed the following tutorial to build a multilingual webpage using php arrays: http://bytes.com/topic/php/answers/880915-how-develop-multi-lingual-websites-php the code: files tree: locale/ english.php french.php set_locale.php index.php locale/english.php: <?php $locale = array( 'title' => 'Title in English', ...

Can I send a fax using PHP?

I have fax numbers and I would like to to send a fax message to each of the numbers programatically. What is the code to send fax message using PHP? ...

Reusing the temporary file created by a file upload in a PHP form

Hi, regarding file uploads, I have a form through which I upload a file, I get the $temp_name = $_FILES['name']['temp_name'] and store it in a variable. Can I then use that variable again inside move_uploaded_file("$temp_name","$location") inside another form. Will this work?? When we upload a file, there is a temp location created o...

How to maintain the previously selected language (I used php arrays and ?lang=) after clicking a link?

I have the following code: <html> <head> <title><?php echo $GLOBALS['L']['title']; ?></title> </head> <body> <ul id="language-selection"> <li><a href="index.php?lang=english">English</a></li> <li><a href="index.php?lang=french">French</a></li> ...