php

PHP output text before sleep

Hello, I want PHP to output some text, then sleep for a minute and a half, and then output some more text. <?php echo 'Output one.'; usleep(1500000); echo 'Output two.'; ?> My problem is that all text is being put out simultaneously - after having waited those 1.5 seconds. I have read something about a function called flush - but...

Cross-domain PHP calls using jQuery and AJAX

Hi there I have a problem where the server I'm using is not configured to allow PHP or CGI and I need to send a mail using variables received from a form on this server to the owner, like a general enquiry/feedback form. Does anyone know how I can call a simple PHP file on another domain configured to use PHP and then execute the mail(...

mod_rewrite in .htaccess

Hey all, how can I reduce this: www.example.com/index.php?page=viewblog&category=awesome down to this: www.example.com/blog/awesome The above lists all of the blog posts in that category, but I also want scope for adding the title of the post on the end of it as well, like this: www.example.com/index.php?page=viewblog&category=awe...

wordpress sort search results by date .

Is there any special parameter that i can pass to search url to sort it by date . And is there any parameter to increase the number of search results returned ? Thanks ...

php: datetime arithmetic

I'm a bit stuck with the DateInterval class of PHP. What I really want is the number of seconds elapsed between two DateTime stamps. $t1 = new DateTime( "20100101T1200" ); $t2 = new DateTime( "20100101T1201" ); // number of seconds between t1 and t2 should be 60 echo "difference in seconds: ".$t1->diff($t2)->format("%s"); Yet all I ...

Why is `ereg` deprecated in PHP?

Why is ereg deprecated in PHP? I had a lot of functions which used this, now they always give warning. What is the alternative of this too? ...

Array contents not being passed fully from php client to a .NET web service

I want to pass an image as a byte array from php to a .NET web serice. The php client is as follows: <?php class Image{ public $ImgIn = array(); } $file = file_get_contents('chathura.jpg'); $ImgIn = str_split($file); foreach ($ImgIn as $key=>$val) { $ImgIn[$key] = ord($val); } $client = new SoapClient('http://localhost:64226/Service...

Is there a way to include PHP value inside a javascript function?

I want to dynamically tell a javascript which <div> to hide, but I dont know how to send the request to the javascript as it is a client side script. for eg: <? $divtohide = "adiv"; ?> <script language="javascript"> function hidediv($divtohide) { ................ } </script> ...

twitter regex for displaying text as url but not if it is meant as text

Hi, Can someone help me to tweak this regex?? I have this regex for twitter and if I spell a word like this R@chard, it wants to turn it in an URL. On Twitter itself it is displayed correctly. Erasing the last line is maybe obvious, although I don't know much about forming regex expressions. Maybe there is also a smarter one for use w...

Why do you not use C for your web apps?

Hello all, I was having a look at a few different web servers this morning when I came across G-WAN. As I understand, its a web server written in C and you have to make use of it by writing your websites/webapps in C. One clear benefit is speed as the G-WAN site suggests. However, on the forums, the creator of G-WAN asked why not use C...

php WAMP setup - undefined variable error

What settings to change while setting up php WAMP so that undefined variable error is not encountered. I changed setting of register_globals = on but it did not help. ...

Comparing date("Y-m-d h:i:s");

Hi all, how can I make a conditional statement like if date("Y-m-d h:i:s"); is more than 30 seconds after date("Y-m-d h:i:s");. I've previously used something like date("Y-m-d h:i:s"); < date("Y-m-d h:i:s"); + 30, however this doesn't seem to work. Help? ...

Normalizing uri part given base url, with PHP.

First of, I'm doing this for a web crawler (aka spider aka worm...) Given two strings (base url and relative url), I need to determine the absolute url. It is especially confusing when it comes to "SEO friendly" crap, such as: Base url: http://aaa.com/january/15/test Found url: /test.php?aaa How would I know that the above aren't fold...

jQuery code generation lib

I was curious if there was anything for say PHP or Python that was able to generate jQuery components by using calls to a library. So something like this: import jQueryLib Tabs tabContainer = new Tabs(); Tab page1, page2, page3; page1.content = "bleh"; ... tabContainer.children.add(page1); tabContainer.Render(); Does anyone know o...

Why develop websites using PHP frameworks or open source product?

Now days most of PHP web development companies use PHP frameworks or open source products for developing websites but is that a right approach? If so but what will happen to the PHP programmer skill and knowledge? Don’t you think using approaches such as “PHP frameworks or open source modification” will kill the programmer skill over th...

php send multiple attachments with email

Hi I need help to get the script below sending attachments, Im fairly new to php and cant seem to get the attachments working , the email does send but I think the heaaders are corrupt and return garbge as opposed to the attached files $to = $_SESSION['companymail']; $email = $_POST['email']; $name = $_POST['fullname']...

Cakephp, searchable behaviour help, returning empty results.

Hi, I'm using the searchable behaviour from the bakery. It is all set up correctly with no errors, so there is no problem there. However when preforming a search it returns no results. I'm at a loss as to why this is happening because of a lack of any errors. I think it might have something to do with initial set up or the indexing o...

str_shuffle() equivalent in javascript ?

Hello, Like the str_shuffle() function in PHP, is there a function similar in shuffling the string in javascript ? Please help ! ...

How to restrict or limit the html tags a user can enter in a web form, pref. client side?

Hi, What are good options to restrict the type of html tags a user is allowed to enter into a form field? I'd like to be able to do that client side (presumably using JavaScript), server-side in PHP if it's too heavy for the user's browser, and possibly a combo of both if appropriate. Effectively I'd like users to be able to submit da...

How to preselect drop down choices and checkbox options in a form (PHP/MySQL)?

I am creating an update form where previously submitted information from a mysql database is grabbed to populate the current form. So this is what I have so far: $select = mysql_query("SELECT * FROM some_table WHERE id = $id"); while ($return = mysql_fetch_assoc($select)) { $name = $return['name']; $bio = $return['bio']; $ma...