php

In what scenarios is it better to use json_encode() than to use serialize()?

That's about all I need to ask. Checked the PHP manual and saw a user post saying that serialize is 45-90% slower than json_encode (he ran some benchmarks). But how "slow" is slow? I can find a lot of "versus" stuff sprawling around but none of which a beginner like me can relate to. I just wrote a script that encoded an array in json ...

Why is there an extra empty row when splited by multibyte punctuation?

Try this: $pattern = '/[\x{ff0c},]/u'; //$string = "something here ; and there, oh,that's all!"; $string = 'hei,nihao,a '; echo '<pre>', print_r( preg_split( $pattern, $string ), 1 ), '</pre>'; exit(); output: <pre>Array ( [0] => hei,nihao,a ) </pre> ...

How to deal with multiple values of <select> in PHP?

<select id="industryExpect" multiple="multiple"> <option value="1">item1</option> <option value="2">item2</option> <option value="3">item3</option> ... </select> I'm seeing something like : industryExpect=13&industryExpect=17&industryExpect=19 Say,there are multiple value with the same KEY, How to retrieve them from $_POST in PHP? ...

Handling 3xx/4xx requests in a PHP MVC framework?

If say you're utilizing the popular: RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /index.php?$1 [L,QSA] And you're trying to make your mvc web framework handle 404's, if you don't find a corresponding view for a specified URI would you just manually send 4...

PHP's open() function related to session-set-save-handler() function's open parameter

Hello, When writing PHP session data to a database and using the session-set-save-handler() function you must write your own callback functions for each parameter. The first parameter of the open() function is the save path. In the tutorials I've seen they've provided a variable like "$save_path" like so: function open($save_path, ...

Cron, Email, Performace

I am building a system for my client. Its a lot like www.getafreelancer.com. There are 2 types of user: Service Provider and Service Buyer. Service Buyers post projects. Service Providers are notified of any new projects posted, which fit into their classifications. Assume: There are approx 100 qualifications. Service Provider can choos...

PHP Global variable not being imported into session handler

I am using ADODB for connecting to database and I am using the variable $db inside my functions to refer to the database connection. For some reason, the actual $db is not getting imported in the 'write' function: <?php // load ADODB class include(DIR_WS_CLASSES . "adodb5/adodb.inc.php"); $db = NewADOConnection(DB_TYPE); $db->Connect(...

Importing MS ACCESS DB to mySql?

I'm working on a project atm, and I need to import data that is stored in a MS ACCESS database to mySql. For mySql I'm using phpMyAdmin on a Ubuntu machine, I have another Windows Machine where I can access the Access DB from, In MS Access 2003 I can't find an option to convert the data to mySql? Can this be done? ...

PHP error missing arguments twitter oauth

I am using the function below function GetTwitterAvatarOauth($oauthtoken, $oauthsecret){ $to = new TwitterOAuth($consumerkey, $consumersecret, $oauthtoken, $oauthsecret); $content = $to->OAuthRequest('https://twitter.com/statuses/friends_timeline.xml', array('count' => '50'), 'GET'); $xml = simplexml_load_file("$content"); $imgurl = $x...

How do I handle user roles effectively?

That's kinda vague so here's the meaty stuff: I have seen authentication systems that do one of the following have a separate role table for each roles, and a separate permissions table, all users in one table have a separate table for administrators there's a lot that I have missed, I know. But what I'm trying to really ask is: Ho...

Simple Database Design Question

Hi, I am developing web application that powered php and mysql. I have table named users, in this table i store some information such as username, first and lastname, telephone number etc.. In my application user can enter some OPTIONAL information such as e-mail newsletter options, company name(if works..) or web site url. All of these ...

Performance issue with Apache, PHP and Symfony~

Updated: ================================================================ I finally found the reason with oprofile. It was because the routing cache of Symfony. We have lots of pages with different urls and symfony caches them in one file (serialized data). So the cache file grows large and it needs more CPU to serialize and unserialize...

kses v.s. strip_tags

kses (http://sourceforge.net/projects/kses/) or just strip_tags, which to use? ...

REST user authentication

OK... the basic idea is to have SERVER and CLIENT physically separated (two systems). My idea is to build a stand-alone web service (REST, XML, API-KEY) that will provide Authentication: User login, logout Data: Get list of products Then I will create clients in different languages (Flash, PHP, JavaScript). Data will be served only ...

Has anyone ever successfully tracked down uncaught exception during ajax request?

How do ajax know whether it failed or succeeded if server side doesn't echo anything back? $.ajax(error:..,success:..) I met with this exception in my test: uncaught exception: [Exception... "Component returned failure code: 0x80040111 (NS_ERROR_NOT_AVAILABLE) [nsIXMLHttpRequest.statusText]" nsresult: "0x80040111 (NS_ERR...

What not to forget?

I'm currently working on an ajax-based application using PHP on the server-side and javascript(jQuery) on the client-side. I want to make sure my application is as secure as possible and need to know what things are absolutely necessary to do before launch of such application. What to check and what are the most vulnerable areas? I'm not...

how to obtain a username from oauth key in twitter

I am working with twitter's oauth, and ive run into a weird problem. How do i get a user's profile information using just their token and secret? Here is what im using now function OauthGetProfile($consumerkey, $consumersecret, $oauthtoken, $oauthsecret){ $to = new TwitterOAuth($consumerkey, $consumersecret, $oauthtoken, $oauthse...

create search option for local webpages by tagging a page

Hello, My actual question is how would I go about creating a autocomplete dropdown off tags that will refer to a particular page, like on this site. I already have a autocomlete dropdown and it looks in the db field for a word starting with something% (wildcard),but that is just one word What if you would have like 5 tags, comma sepe...

Regular expression to put <P> AND <ul>/<ol> into array

I'm searching for a function in PHP to put every paragraph element like <p>, <ul> and <ol> into an array. So that i can manipulate the paragraph, like displayen the first two paragraphs and hiding the others. This function does the trick for the p-element. How can i adjust the regexp to also match the ul and ol? My tryout gives an err...

How to keep database connect alive?

I'm using ajax, and quite often if not all the time, the first request is timed out. In fact, if I delay for several minutes before making a new request, I always have this issue. But the subsequent requests are all OK. So I'm guessing that the first time used a database connect that is dead. I'm using MySQL. Any good solution? ...