php

RTF file upload in PHP and problems with UTF

I want to create a web form which will allow the user to upload text/rtf files in UTF-8 having foreign language content using PHP and then execute a series of commands on it via the exec() function. After this processing I would be giving it back to the user as a download. I made rudimentary form in html with a file input form and submi...

ImageMagick: Tiff to PDF from PHP

How can I convert 2 tiff images to PDF, I already knows how to get the image out of the DB, and I print it using echo and setting up the MIME type. But, right know I need to use a duplex printer option, so I need a way to generate a PDF from inside my PHP page, that PDF must containt both TIFF images (one per page) How can I do that? Wh...

PHP Rounding Numbers

I cannot seem to figure out how to always round up in PHP. ceil() would be the obvious choice but I need the same functionality that round() provides with its second parameter "precision". Here is an example: // Desired result: 6250 echo round(6244.64, -2); // returns 6200 echo round(6244.64, -1); // returns 6240 echo ceil(6244.64) // ...

trying to send array through GET variable, when printed, var equals string of 'Array'

Whenever i build a URL i.e. cart.php?action=add&p[]=29&qty[]=3&p[]=5&qty[]=13 and try to grab the p variable and the qty variable, they = 'Array' var_dump = array(3) { ["action"]=> string(3) "add" ["p"]=> string(5) "Array" ["qty"]=> string(5) "Array" } i create half the url with php, and the other half is concatenated with ja...

help with array

What am i doing wrong here? The username string is less than 2 chars but it still dont set error[]? Register: $errors = array(); $username = "l"; validate_username($username); if (empty($errors)) { echo "nothing wrong here, inserting..."; } if (!empty($errors)) { foreach ($errors as $cur_error) $errors[] = '<li ...

Is there a function to find the absolute root path in php?

for example: /home/mydomain.co.uk/public_html/ Something generic for windows or linux? Id like it to produce the root path only regardless of where i call the script from. So not the absolute root path to my script. Sorry is this is hard to understand. ...

getting RSS feeds on website

Hi, I had this code that I wrote last year and it returns RSS feeds for some term I enter: <html> <body> <form name="form" action="search.php" method="get"> <input type="text" name="q" /> <input type="submit" name="Submit" value="Search" /> </form> <?php require_once "RSS.php"; // want to parse the $row[1] variable to get out...

KohanaPHP 3 core throwing an error

I'm getting a ErrorException [ 2 ]: fopen(Unknown) [function.fopen]: failed to open stream: No such file or directory ~ SYSPATH/classes/kohana/core.php [ 1213 ] after I finish the 'install'. It's the same problem as featured here , but I still don't find a solution to it. Anyone with experience with this ? ...

Loop not looping fully on actioning on first iteration

I am doing a multiple upload using the Multiple_upload library in codeigniter, and form some my loop that creates thumbnails only fires on the first iteration it would seem here is my code function saveContentImages() { $this->load->model('categoryModel'); if($query = $this->categoryModel->getCategoryByContentId($this->input->po...

PHP competency test?

Are there any good free PHP competency tests out there? It's easy for someone to say they code in PHP, but depth and understanding of how lowerlevel parts of the language are parsed and executed is much different. Something that asks good questions, perhaps elicit the person to write some sample code solutions to particular problems. I...

What are good PHP and MySQL type Blogs to read?

I searched and found many topics similar to this on Stackoverflow, but they were all for languages that I do not use. I am interested in reading good blogs with an RSS feed in topics related to PHP, MySQL, Javascript, jQuery. I have a few listed below so far, please share with me any blogs worth reading and subscribing to with any of t...

check if a user registered within the last hour

I have this piece of code to check if a user has already created an account the last hour: $result = mysql_query("SELECT * FROM accounts WHERE registration_ip = '$_SERVER[REMOTE_ADDR]' AND created > ".(time() - 3600)); if (mysql_num_rows($result) > 0) exit('Blablal') It does not exit as I want it do, i can make how many accounts ...

Combining multiple htaccess rewrite rules into one

First, let me say this: I suck at regex and htaccess. I'm trying to make a rule that will properly parse url segments into variables. So far I have this: RewriteRule ^([^/]+)/?$ index.php?query[]=$1 [QSA,L] RewriteRule ^([^/]+)/([^/]+)/?$ index.php?query[]=$1&query[]=$2 [QSA,L] RewriteRule ^([^/]+)/([^/]+)/([^/]+)/?$ index.php?query[]=$...

Create PHP array from MySQL column, using auto_increment column as index

Hi, Much like this previous question, I wish to store a MySQL column in a php array (as opposed to storing by row). However, I want the array indexes to match those of the database's primary key. For instance, for the following database: id name 1 Joe 2 Mary 9 Tony $name['9'] == "Ton...

Column-level UTF-8 in Doctrine

Does Doctrine support setting individual columns to charset UTF8? Documentation seems to refer to table-level only. Please advise. Thanks. ...

How to query a database from view - CodeIgniter

Hello, I have query that runs in the controller: $data['query'] = $this->Member->select_sql($id); $this->load->view('myform'); and then outputs data in the view: foreach ($query->result() as $row): echo $row->post_title; echo $row->post_user_id; endforeach; So this outputs me a list of posts made by a user. Now I would l...

PHP based Spell check control

I am developing a web site where i need to accept data from user. What i am looking at is some spell check where as and when user types it shows the suggestion. Like the box we use in while type the question in Stackoverflow. It should be based on PHP. I am looking free opensource which i can use in my project. ...

PHP PECL_HTTP vs cURL Extension

I'm working on a PHP Client for CouchDB. While browsing through the php.net documentation regarding HTTP and cURL, I came across the PECL_HTTP Extension. At first glance, I think I would like to use this PECL extension instead of cURL because it's much simpler to use, and I'm not doing very complicated HTTP work anyways. Plus I always li...

SMTP server response: 451

I've build 2 contact forms (quote.php and contact.php), validated with jquery and submitted with to separate ajax_contact.php and ajax_quote.php files. They've both been built on the same template I've used on other sites, but for some reason the ajax_contact.php is returning this error: Warning: mail() [function.mail]: SMTP server resp...

Limiting while loop

Hi Is there a way to limiting while loops when fetching data from mysql ? $query = "SELECT * FROM `table` WHERE user_id = '$id' ORDER BY `ID` DESC"; $result = mysql_query($query); while ($info = mysql_fetch_assoc($result)) { //stuff } Here i dont want to use mysql's LIMIT function, can i limit while loop other t...