php

Zend_Lucene CJK support

Does someone know if Zend_Lucene class support CJK (Chinese Japanese Korean). I want to use it on my own website the only problem it should work for both English and Japanese language. Also if someone has some ressource about CJK version of the Java version would be appreciated also. Thanks ...

Problem with CURL (Multi)

I'm having a problem with curl_multi_*, I want to create a class / function that receives, lets say 1000 URLs, and processes all those URLs 5 at a time, so when a URL finishes downloading it will allocate the now available slot to a new URL that hasn't been processed yet. I've seen some implementations of curl_multi, but none of them al...

PHP Login System

I am creating a login system for a web application using PHP. My question is, is it safe to only store the user login information in the current session? For example, if a user named John logs in successfully to my site, can I just store $_SESSION['Username'] = 'John' and $_SESSION['LoggedIn'] = 1 then check that $_SESSION['LoggedIn'] ...

Appending metadata to a newly created image via php?

I have php script that creates a temporary watermark image for users that are not logged in. The original image contains IPTC (metadata) information that I would like to retain, however, when the watermark is applied and imagejpeg is called, all metadata is removed. Any ideas how I can maintain the metadata or re-apply metadata after i...

nl2br more than one newline

Hi, I am using nl2br to convert nl chars to tag but for ex i want to convert "Hello \n\n\n\n Everybody" to "Hello Everybody" also i want to convert multinewlines to one br tag. How can i do this ? ...

Validate string without special characters

i have a problem. i what to get info about my string have ordre chater in ( a-z A-Z 0-9 and - _ ) if my string have ordre its return false or not return true. i hob i can get help to this problem. ...

How can I use a PHP function inside of another function?

I need to use a function inside of another function, how can I do this? I realize that the function is out of the scope, I do not understand OOP and classes yet. can someone help me? function some_function ($dfd, $characters, $dssdf, $sdfds){ $sdfs = 'sdfsdf'; //random stuff goes on //this is where my trouble begins I hav...

PHP Specify the Return Type Hints for a Method

What is the correct syntax for me to specify the return type hints for a method? For example, I have such a method: private static function ConstructPDOObject($dbname) { $hostname =self::HOSTNAME; $username = self::USERNAME; $password = self::PASSWORD; $dbh = new PDO("mysql:host=$hostname;dbname=$dbname", $username, $password...

How can I inject PHP code at certain points of a string variable?

I have a class that stores paths to CSS and Javascript files in arrays. This class also compiles my final page HTML output (which is stored in an $output variable). I want to loop through my $css and $js arrays and inject HTML at specific points in $output. The CSS files would need to go right before </head> and the JS files would need t...

What is the most scalable PHP-based directory structure for a large site?

I am creating a very large PHP MVC-based site that will have a large library of php classes, javascripts, and many css files (not to mention a large amount of files for the MVC). For the first time ever, I am actually taking the time to plan out a clean and organized directory structure. What directory structures do you typically use, ...

PHP PDOStatement: Fetch A Row, as the First Column as the Key of an Array

I am using PDOStatement to query the database. Whenever I get a returned row, I want it to be fetched into an array, with the $row[0] as the key, and the subsequent elements in the row as the values. I can, of course, write a combination of foreach loops and if conditionals to do the job, such as the below: private static function GetM...

Cache data in PHP SESSION, or query from db each time?

Is it "better" (more efficient, faster, more secure, etc) to (A) cache data that is used on every page load in the $_SESSION array (but still querying a table for a flag to reload the data fresh), or (B) to load it from the database each time? I'm using the cache method (A), but I'm worried that with hundreds of users, memory could beco...

CakePHP joining Models between two tables, twice

I have a question about how to set up the relations between two models when they join to each other in two different regards. I'll give an example of the problem I've got: Users (id, name) Messages (id, message, from_user_id, to_user_id) (In my case, it's not users nor messages, but this hopefully illustrates the problem in a simpler...

PHP syntax displaying in HTML source

Hi all, In my CMS I've added this code <div><?php include("my_contact_form.php") ?></div> which updates to a db. I can see it there OK. I have this php code in my display page after the db call: $content = $row['content']; when I echo $content inside the body this is displayed in the HTML source: <div><?php include("my_contact_form....

REG_EPAREN in php

Im using eregi() function for matching the string but it is giving the following error :- PHP Warning: eregi() [<a href='function.eregi'>function.eregi</a>]: REG_EPAREN in /a/b/c/mysite/file.php on line 59, referer: xyz.com im using this function here :- if(eregi($check,$in)) { $titles=ucfirst(substr($desc, 0, 38)); } else { ...

PHP - Loading CSS using cookie, but cookie isn't being read?

I currently have a web site where users can select a custom theme. After they choose the theme, a cookie is created. The cookie contains the correct data and points to the correct CSS file. For some reason, upon re-visiting the site, the theme is not loaded. I should point out that I am new to PHP so it may be a very easy mistake. P...

Not able to pass value from a select list in a simple crud form?

Hi, I have written a simple CRUD form which has one select list. However the value from the select list doesnot seem to get passed to the database. it get passed when I am using a simple text box. What is the possible error? Please point out <?php include('config.php'); if (isset($_POST['submitted'])) { foreach($_POST AS $key => $value...

How to get id of the last updated row in mysql

Hi friends, I just want to get id of the last updated row in the mysql using PHP. Thanks in advance... ...

In php, my html prints out with � all over the place - is there a fix?

Hello I have two php file. One of them builds a report, the second contains the language text. When it prints, it keeps giving me the � special character everywhere, even if I am not using any special characters in my code. Why is that and how can I get rid of those? I am running Apache 2.2, php 5, Ubuntu 8.04. FILE 1 <?php function g...

php - How can i manage users permission?

How can i manage user permission? i need a fast method to manage users (accsess to a page or dont accsee to a page) when they login? Please help me ... ...