php

Cleaning up PHP.

Is there anyway I can clean up if($class == 2 AND $posts >=1){$showpost ="1";} else {$showpost ="$posts"; if($class == 3 AND $posts >=2){$showpost ="2";} else {$showpost ="$posts"; if($class == 4 AND $posts >=3){$showpost ="3";} else {$showpost ="$posts"; if($class == 5 AND $posts >=4){$showpost ="4";} else {$showpost ="$posts"; if($cla...

How to trim out the space between non letters with PHP?

Say,should keep the space between letters(a-z,case insensitive) and remove the space between non-letters? ...

How to save text in php as a pdf file?

I have textarea in my site(link shortening site) i want to user enter some kind of text and as a return i will give(shorten link) a pdf file which user can download.How can i do that with php do i need extra library or default php libraries are capable of doing that?(i am working on windows machine by the way)(site using php mysql apache...

PHP - Using a drop down list to change site theme

I have a drop down list where users can select a theme for the site. The only problem is, I'm not quite sure how to properly load the theme once they press "Apply". I am new to PHP. I know if I use GET, it will pass the variables through a the current page and add them to the end of the URL. I would really like to avoid that. So, I g...

Cleaning up PHP, and cleaning up unnecessary code.

I'm still new to certain PHP functions. Is there any way I can clean up the following code, because I know all of this is just unnecessary, and it's giving me a headache. Everything after the if statement is the same for each set of code. if($class == "2"){if ($posts >= 1){ $sql = "UPDATE users SET posts=posts+1,tposts=tposts+1,poin...

php output buffering callback problem

here is the code ob_start(array(&$dispatcher, 'outputCallback')); include($file); ob_end_flush(); function outputCallback($string) { if(ob_get_level() == 1) { $static =& ParserStatic::getInstance(); return $static->insertToppings($string); } return false; } the problem is when i return $string it b...

How to kill a process which is spawned by proc_open

Hello , I have a PHP script where I create a new process using proc_open().It executes for about 2 hrs, at the end I have a proc_close(). Sometimes I need to stop this process in the middle , how do I kill/signal it to stop and free up the resources in PHP ...

ezPublish experiences

Facing a need for a single CMS we can use for rapid deployment of customized CMS solutions, I am wondering if anyone can share any constructive feedback, experiences, pros and cons of this, seemingly powerful, piece of software. The whole story/marketing pitch sounds solid, and from a quick glance at the CMS itself things seem to be put...

PHP Problem Solving

What's the best way to create a PHP form that takes a users input in the form of five decimal numbers: displays the five decimal numbers display the sum of the five decimal numbers display the average the five decimal numbers display each number rounded to the nearest integer? ...

Page load time with Cookie vs Session in PHP

I have a social network type site (member site) I store a lot of user data like username, userID number, email, first name, photo URL, into a user session when the user logs in to cut down on the ammount of DB queries per page. I sometimes hear people talk about using cookies for some things, I realize cookies should never be used for u...

Convert vCard Bulk Contact File to Single .vcf files

Hello Guys... I recently had an issue... I wanted to transfer my contacts fro my LG U990 Viewty to my iPhone 3GS I exported the contacts from my LG to a vCard File containing all the addresses all in one as BEGIN:VCARD VERSION:2.1 N;CHARSET=UTF-8:A; TEL;CELL;CHARSET=UTF-8:*121# REV:20120720T081000Z END:VCARD Now the above format repe...

Encoding problem (UTF-8) in PHP

Hello! I want to output the following string in PHP: ä ö ü ß € Therefore, I've encoded it to utf8 manually: ä ö ü ß € So my script is: <?php header('content-type: text/html; charset=utf-8'); echo 'ä ö ü ß €'; ?> The first 4 characters are correct (ä ö ü ß) but unfortunately the € sign isn't correct: ä ö ü ß € Here you...

Deleting from a table results in a Cardinality violation

I have a method that deletes a row form a database using the sql adapter provided the the zend framework. class Table extends Zend_Db_Table_Abstract { ... $where = $this->getAdapter()->quoteInto( 'ModID=? AND URL=?', array((int)$mid, $url->toString()) ); $this->delete($where); The issue is that this ...

Ajax call to php function in a controller.

I am using the below jquery code to call a ajax function in my contorller CS. Search is the function name. How ever the function is called in the controller. But i am supposed to get a value in the text box of the page inside this function. Basically this is for the auto complete feature. on key up the function is called. But i am not ab...

Having problems with captchas and headers (PHP)

Hi, I'm trying to add a captcha to a site somebody else has made. I've been following this tutorial and if I make it in a separate file, it works just fine (so it's not an issue with the server setup) However, when I try to add it to an existing page, it's not working at all. When I load the page in Internet Explorer, the source code i...

Is this a stored procedure?

IS this bit of code in PHP/mysql considered a stored procedure? $sql = 'SELECT username FROM user WHERE username = ? AND passwordHash = ?'; $result = $db->query($sql, array($_POST['username'], $passwordHash)); ...

Convert pdf,doc,ppt,xls files to html using php

Hello friends, Actually I want all files view as html like gmail in view as html. I have used below code for doc view as html but here not displaying font style (bold,color,etc...) function parseWord($userDoc) { $fileHandle = fopen($userDoc, "r"); $line = @fread($fileHandle, filesize($userDoc)); $lines = explode(chr(0...

Removing specific characters from a string in php

Hi How can I check a string in php for specific characters such as '#' or '\'? I don't really want to use replace, just return true or false. Thanks ...

How to terminate a process

Hello , I am creating a process using proc_open in one PHP script. How do i terminate this in another script . I am not able to pass the resource returned by the proc_open. I also tried using proc_get_status() , it returns the ppid . I don't get the pid of the children . development env : WAMP Any inputs is appreciated . Mit...

Drupal: updating with Drush doesn't change update status

I've updated my drupal installation and drupal modules, but admin/reports/updates says that Drupal version is still 6.12. To update drupal I ran - drush updatecode - drush updatedb (this updated only modules and said code still needs to be updated manually). Then I uploaded core, unzipped it, allowed to overwrite older versions and again...