php

simple PHP preg_replace question

Here's a simple preg_replace $string = 'src="index.php'; $string = preg_replace("/(src=('|\")+[^(http:|https:)])/i", "src=\"http://domain.com/", $string); echo $string; I expect the result to be src="http://domain.com/index.php but it turns out to be src="http://domain.com/ndex.php. I must be missing something here.. ...

logging MySQL response from PHP page

When I insert a record, I get the message "1 row affected" and while updating "Rows matched:1 Changed:1" How do I get these messages from PHP code? mysql> insert into mytest values ('103'); Query OK, 1 row affected (0.26 sec) mysql> update mytest set id = 12 where id = 10; Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1...

Define Default Charset for htmlentities()

I was wondering if there were any way to define the default encoding for htmlentities(). I have a big project going that uses htmlentities calls all over the place, and was wondering if there was a simple way to set it from ISO-8859-1 to UTF-8 as the default character encoding, using something simple like init_set. Or possibly with a sep...

How to redirect back after login in PHP

Sometime we get link from a site, when we click the invitation link, it just send us to the index page for login(as we are not logged in in that site), when the login finishes, the site just redirect us to the link on which we clicked. How this can be achieved in php? ...

PHP getimagesize() alternatives without javascript?

Say I have the URL of an image, and URL file-access is disabled in the server configuration, and that's not something I can (or want) to change, is there an easy way to get it's height/width using PHP? I'd prefer not to use javascript if possible. ...

Not displaying the country name (in 'Hindi' language)?

Not displaying the country name (in 'Hindi' language) in <th></th> tag?, but displaying country name in hindi in tag correctly Let me know the reason please Iam using php ...

what are the Advantages and disadvantages of running php on windows

the linux environment is natural to php, what are the Advantages and disadvantages with run php on windows ? Are there some limits in windows ? what is the best (lamp/wamp) in term of performance ? thanks ...

How can I get the key of a colum in cassandra using php?

How can i get the keys of the column having sex = male. Using the php library from http://wiki.apache.org/cassandra/ClientExamples For example my keys are 0,1,2 key: 0 { column( name:age, value:24), column( name:sex, value:female) } key: 1 { column( name:age, value:24), column( name:sex, value:female) } key: 2 { column( name...

Cakephp routing with optional params

I have a method in my users controller similar to: function members($type = null, $category = null) { ... } Both params are optional and can be used together or on their own. So with the following route. Router::connect('/members/*', array('controller' => 'users', 'action' => 'members')); http://example.com/users/members successfu...

How to avoid changing the address in the address bar in PHP..

Dear all, This is Praveenkumar. I have one doubt with the address bar. I creating a website. Something like this http://localhost/Website/index.php is the starting page. If i give .../Website/home.php it goes to that page. So i think it is not good for the website. If anybody can goes to any of the page they know the address. So i want ...

How do I detect when a user has been idle for a certain time and destroy their session in PHP?

I would like to have my PHP website destroy a users session if they have been idle for 5 minutes. If this does happen, I'd like to present the user with a message stating why they were logged out and redirect them to the login page. What is the best way to handle this? I am running on php and myadmin. Thanks Avinash ...

What are some good PHP profilers that can be used?

I ve studied about profiler in php... Now i want to know What are some good PHP profilers that can be used? ...

Opinion on sending emails from php.

I'm preparing a website that will send email notifications to registered users. From my experience I know, that sending emails is somewhat a painful process for PHP, especially when we're talking about thousands. One of my websites sends email every now and then to 1000-1500 people. It takes around 5mins for PHP to accomplish that, so we...

Button to call a php function?

I am new to javascript world. I wrote a function in PHP. How do I call it when I click a button or image in html? ...

How to handle and identify multiple sub-domains

Hi, I am planning for multiple sub-domain names based on city, something like city1.mydomain.com, city2.mydomain.com, ... All sub-domains will point to same file structure on main domain. Then in my program I would like to capture the city name and display content based on city. What is the best approach to identify the city (based on ...

why making a user registration must be regular?

hello, everyone. I'm programming a user registration. However, I found a charactor limiting to 'username' from sample codes, such as just '.', ''', '-' are accepted, no space or other blank, etc. Are those restrictions necessary? I'm using MySQL+PHP. If I adopt the following several ways: change the collation of the column to '...

Extra backslash needed in PHP regexp pattern

When testing an answer for another user's question I found something I don't understand. The problem was to replace all literal \t \n \r characters from a string with a single space. Now, the first pattern I tried was: /(?:\\[trn])+/ which surprisingly didn't work. I tried the same pattern in Perl and it worked fine. After some trial...

How i can i delete a selected item out of a listbox using php,javascript?

I got 2 buttons. One is to add an item to the listbox. The other is to delete something out of the listbox. The filling happens with an array. So what I need to know is: how can i delete a selected item out of the listbox? Thanks Stijn ...

Count words like Microsoft Word does

I need to count words in a string using PHP or Javascript (preferably PHP). The problem is that the counting needs to be the same as it works in Microsoft Word, because that is where the people assemble their original texts in so that is their reference frame. PHP has a word counting function (http://php.net/manual/en/function.str-word-c...

MySql Error 1064

Sql: create table autori( id_autor integer primary key auto_increment, nume varchar(50) not null, prenume varchar(50) not null )Engine=InnoDB; create table domenii( id_domeniu integer primary key auto_increment, nume_domeniu varchar(50) not null, descriere varchar(1000) not null )Engine=InnoDB; Php: $sqlpath = "fil...