php

How do you compare two text files with different line endings in PHP?

I need to compare two text files in php. One file is user uploaded, and the other is supplied by the server, running on windows. This works fine when the file is submitted from another windows computer, but from a linux computer the files come out different, I am assuming this is because of different line endings. Is there an easy way t...

php eclipse debuging

I am runing a php script using eclipse. when a set breakpoint and run the script it throws me this error. form the error it is apparent that i have change something the php.ini file. but i dont know what i have to change to make either zend or xdebug. even i dont know what the differnce b/w them. following the error The session could ...

How to create e-book store with php?

How do I create a downloadable ebook store with PHP? Please suggest any tutorial! ...

An easier way to define these variables?

$access_community = 1; $access_content = 1; $access_tools = 1; $access_administrator = 0; $access_moderator = 0; Just wondering if there's an easier way to write this using an array? This seems like overkill. Thanks! ...

Public API design - handling failure with a http code? Is that REST?

I am just about to make a webservice available for fellow programmers in my sector using PHP on my own server. As this is the first time I have done this, I first investigated APIs that I frequently use, Flickr etc. My service returns granular data extracted from a very large csv file by examining GET arguments, it is read-only. The ...

How can i detect whether a string is not written in english

Possible Duplicate: detect language from string in PHP is there any function in php with which i can assume that there are not any english characters written in a particulsr string. ...

How do I maintain text layout when using file_get_contents?

Let's say I have the following text file: This is the first line of the text file. This is the second line, and here goes the third. When using echo file_get_contents($_SERVER{'DOCUMENT_ROOT'} . "/file.txt"); The output is This is the first line of the text file. This is the second line, and here goes the third. How do...

Num Rows always ='s 1 for some reason. QUICK FIX

I don't know if i am doing it right, this is what I got: while($row = mysqli_fetch_assoc($result)) { $items = mysqli_num_rows($row); } It always sets $items = to 1 for some reason. Here is my mysqli_query... $top10_query = "SELECT * FROM users WHERE userid='$userid'"; $result = mysqli_query($cxn, $top10...

Getting last and next db-record by date in MySQL-Table?

Hey guys, I've got a certain question related to a blog, which I am developing in OOP (PHP) right now. All blogposts are stored in a MySQL-table. In the app you can read a specific post by giving the id of the post via GET-parameter. So like http://example.com/?id=2. Under the blogpost I want to show to navigation links like "previous"...

What to do after learning basic PHP?

I have learned extremely basic PHP(I think so) using Lynda Tutorial( http://bit.ly/aCIhiu ). After that, I feel, I got some grip on that language. My ambition is to become a web developer! After some googling, I planned to learn some more advanced and practical php by using websites like PHPSCripts, Webapps etc.. But, now I'm in a confu...

What is the shortest way to get the next free id from MySQL table ?

I have a table with id column. ids are in ascending order but not necessarily consecutive. For example: 1, 2, 3, 5, 6, 10, 11, 12 I need to find the next "free" id, i.e. max(id) + 1 (or 1 if the table is empty). Currently I'm doing this in PHP like this: function get_free_id($con) { $sql = "SELECT MAX(id) AS last_id FROM Table"; ...

PHP: by-reference-function with boolean as return value – strange notice

I have a function which returns a referenced value by default – however, the function should return false if something went wrong during processing things in the function. The function is declared as follows. function &find($idx, $pref_array = false) { if ($pref_array === false) $pref_array = &$this->preferences; fore...

AVG() fuction always returning "Array"

This is what I got, UPDATED $avg_query = "SELECT AVG(rating) AS avg_rating FROM kicks WHERE userid='$userid'"; $avg_result = mysqli_query($cxn, $avg_query) or die("Couldn't execute query."); $row = mysqli_fetch_assoc($avg_result); $average = $row['avg_rating']; E...

Domain (country) realted banners in PHP based system

I have an PHP based Youtube clone system installed on our server. The same system is used in couple of countries. Let's say that I have 3 domains that all point to the same system: www.site.hr www.site.ba www.site.rs They all redirect to some site named www.site.tv These 3 countries have very similar languages so it makes sense to h...

PHP array_push not the right function, what to use?

array_push($array, getData()) gives me: Array ( [customer] => One [itemno] => Yellow Ribbon ) Array ( [customer] => One [itemno] => Blue Band ) Array ( [0] => Array ( [customer] => Two [itemno] => Red Tape ) ) But what I want is: Array ( [customer] => One [itemno] =...

extract long/lat from a string

HI, I have a string that could contain a longitude and a latitude. The string could contain anything but if it does contain a lon/lat then I want to extract it using php. I think I need a regular expression but I don't have a clue how to get that out. The string could contain anything: a random string dfdff33338983 33.707352,-116.27279...

How to get images from over webscope using PHP?

Hi ! How can i display an image on my webpage which i located above webscope? The image is located at /home/image.jpg and the website is located at /home/www/example.com/index.php which refers to http://example.com/. I have tried this code to retrieve the image, but it does not work :( header('Content-type: image/jpeg'); read...

PHP Grouping an Array

I have an array: Array ( [customer] => One [itemno] => Yellow Ribbon [price] => 1,2 ) Array ( [customer] => One [itemno] => Blue Band [price] => 0,5 ) Array ( [customer] => Two [itemno] => Red Tape [price] => 2,0 ) And I want to group it by customer like this: Array ( [One] => Array ( ...

Drupal - make the cancel link on the confirm page a button

When I press the delete button on some content, I'm taken to a confirmation page. The delete option is a button, while the cancel option is a link. That looks pretty weird. I found that there's a form_confirm() function in drupal, but I can't understand how to use it. Does anyone know how to make the cancel link into a button? ...

PHP regex replace expression with function run on its part

Hello, I have a simple text that is being parsed with PHP. In that text, I sometimes use following syntax: Here's the text... {$video:path/to/my/video.mp4} and here the text goes on. Now, what I need, is, by means regex, to replace this {$video:path/to/my/video.mp4} with the returned string of this: $someObject->processVideoSource('p...