php

What sould be a http response code for lack of PHP session based authorization

I am writing a small website. There is PHP session based authorization. What HTTP response code should I send, if a user doesn't have access to a certain page? Is 412 Precondition Failed a good idea? I think 401 Unauthorized is good only for a http authorization. 400 Bad Request and 403 Forbidden looks too general. ...

How to call shell script from php that requires SUDO?

I have a file that is a bash script that requires SUDO to work. I can run it from the command line using SUDO but I will be prompted to put in the SUDO password. I want to run this script from php via shell_exec but I if I call SUDO, its not like a command line where I can be prompted for the password. Is there a way to pass the passwo...

Symfony - updating unique column - validation problem

I'm new to Symfony Framework and I ran into a problem with form validation. I want to update data in DB including unique column, but if unique column is unchanged, an error is returned (An object with the same "domain" already exist."). Domain column must be unique, but user should be able to change it. So, if one user saves his domain ...

How to send Chat Invitation, to GTalk using PHP?

I want to send Chat Invitation to multiple users of Gmail, from my database list. How can it be done using PHP? example: My data table contains some list of email address(i.e [email protected], [email protected]....), and i want to send all these email address an invitation from my end(i.e [email protected] or [email protected]) ...

Referring to a static variable from a static method of the same class

You have a static function: public static function foo() In the same class you have a static variable: public static $uaa How do you refer to $uaa from foo()? ...

Match a field from a form's contents with a table in a database (MySQL)

I have set up a form on my site. And I'm wondering, how can I match what people enter in a field in that form with something in another table. The form submits to one table, and I want to check if what's submitted with the form is in another table. In this case, I have a field named "Title", and I want to check if what's been entered fr...

problem in decoding htaccess url rewrite values

i have written a code in .htaccess RewriteEngine on RewriteRule ^category-search/(.*)$ category-search.php?cat_id=$1 and my current URL is www.mydomain.com/category-search/=NA== Last values (=NA==) is encoded in base64_encode. But when i m trying to fetch this values in php like... $val=mysql_real_escape_string(base64_decode($_REQU...

PHP - SPL vs array:: When should we use SPL and when we should use array in php5?

Hi, In java and C++ when we dont know the size - array not used like in php, instead used linkedList etc.. In php exist SPL, but most of the times programers use array, why(because peaple don't know about spl )? When we should use in php5 array and when SPL and what the difference in this case between PHP and Java/C++? Thanks ...

Google Buzz API OAuth Problem - Using Zend_OAuth (PHP)

I have successfully gotten an access_token, so it's not a problem with the 3-legged process. The problem starts when I try to add a new post/activity using the Buzz API... Here is my request: POST /buzz/v1/activities/@me/@self?alt=json HTTP/1.1 Host: www.googleapis.com Connection: close Accept-encoding: gzip, deflate User-Agent: Z...

Highlight in PHP

Possible Duplicate: highlighting search results in php/mysql I am doing a search with a query, in MSSQL, like this: SELECT ctext FROM Table WHERE ctext like '%filter%' Then, I am wanting to highlight the hits with php: function highlightme($str, $filter){ $html = "<FONT style=".chr(34)."BACKGROUND-COLOR: yellow". ...

How to better submit a form?

So I started to make comments module and came to conclusion that I'm not sure how to better do the comment submitting. This is the code I've for comment submitting form. <form action="/rq/comment.php" method="post" id="pcomment" onsubmit="return rq('/rq/comment.php', 'pcomment');"> <input type="hidden" name="pid" value="<?=$id?>"> <div ...

How does one implement a MySQL database into a webpage?

I am a complete database newbie. So far, I know that I can connect to MySQL using PHP's mysql_connect() command, but apart from that, I really don't see how to take that data and put it onto a web page. a) are there ways other than mysql_connect() b) lets say I had a table of data in mysql and all I wanted was for that table (for examp...

How to render different variables as you work your way down the page / through the script?

I have a .php file that is rendering as a web page. Is there any way I could change a variable on the fly as the page renders? Currently the page renders like this... I love to eat oranges. I love to eat oranges. I love to eat oranges. But I want it to render like this... I love to eat oranges. I love to eat apples. I love to eat ch...

Find PHP with REGEX

I need a REGEX that can find blocks of PHP code in a file. For example: <? print '<?xml version="1.0" encoding="UTF-8"?>';?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt; <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <?php echo...

Password protected directory and files in PHP

Im creating a simple private page with links to some files to download. I've done it with simple session management but I have a problem: if somebody click on the file-url he can download the file without the authentication. So what I can do to avoid this? I can make a HTTP Authentication but I want a custom login form and not the window...

Best format to send error responses in simple API

I'm writing a simple url-based API that retrieves data and sends it back in one of a few formats (XML, JSON, CSV). I'm kind of on the fence about how to handle error responses. If the user supplies a format then I can just send the response in that format, but what about cases where the user requests an unsupported format? Is it prefera...

Getting a MySQL database difference

I have a mysql database. What I'd like to do is perform an arbitrary action on it, and then figure out what changed. Something like this: //assume connection to db already established before();//saves db state perform_action();//does stuff to db diff();//prints what happened I'd want it to output something like: Row added in table_0...

i search to smarty template engine toturial?

can any one to help me to find smarty template engine toturial ...

What PHP/Shell Framwork can be used to access HTTP-POST/-GET Forms (besides curl)?

Hello, (Hallo!) I'm searching an abstraction layer from pure HTTP-POST/-GET using curl. It should somehow make it easy to define the Targeted script and it's variables. I read something exists in the FreeX (german unix/programming magazine), but don't have the named magazine at hand. What can I do? Stick with curl? What alternatives...

Which function in php validate if the string is valid html?

Hi, Which function in php validate if the string is html? My target to take input from user and check if input html and not just string. Example for not html string: sdkjshdk<div>jd</h3>ivdfadfsdf or sdkjshdkivdfadfsdf Example for html string: <div>sdfsdfsdf<label>dghdhdgh</label> fdsgfgdfgfd</div> Thanks ...