php

php twitter class not working anymore

So I have been using an open source twitter php class I got a few months back, and all of a sudden, it started to throw me errors last night. You can see what is happening here: www.campusmediawatch.org It says it requires authentication but I do authenticate and it has been working for months since last night. Any ideas? Here are the ...

Warning: DOMDocument::loadHTML(): htmlParseEntityRef: expecting ';' in Entity,

$html = file_get_contents("http://www.somesite.com/"); $dom = new DOMDocument(); $dom->loadHTML($html); echo $dom; throws Warning: DOMDocument::loadHTML(): htmlParseEntityRef: expecting ';' in Entity, Catchable fatal error: Object of class DOMDocument could not be converted to string in test.php on line 10 ...

HTML encoding in codeiginiter

I have an issue with the html-encoding in the Input library in Codeigniter. I have a form used to edit the News in the admin side of my project. Here is the HTML code of the title of the news: echo form_input('title',($title) ? $title : $this->input->post('title')); When the edit page is loaded, I'm taking the news title ...

php:how to check if string contains any of the listed keyword ?

i have an array of strings. I have an array of keywords. i loop through each string, and need to store them to mysql database if it contains any of the keywords. currently i am using multiple stristr(), which is getting difficult. is it possible to do something like stristr($string, array("ship","fukc","blah")); ? ...

How to check domain name availability via linux command

I am using checkdnsrr() function in PHP to check for available or parked domains but the result is not 100% accurate. Is there any other method to check a domain name availabilty? ...

Is there a better, more "Standard" way to perform SQL queries in PHP without using a framework?

For the longest time, I've been using the following basic formatting for SQL queries within my PHP: $sql = "SELECT * FROM `user-data` WHERE `id` = '".$id."' LIMIT 1;"; $fn = mysql_fetch_assoc(mysql_query($sql)); While this works flawlessly, it can get really messy for longer bits of code, and something deep inside of my conscience cri...

PHP - regex to reformat JSON

Hi, I've been trying to figure out how to reformat multiple JSON files into a single one using php, but am having a difficult time understanding how to use complex regular expressions. Suppose I hade multiple instances of the following JSON data: { "felines": { "cats": [ { "age": 7, ...

Cannot start session if documents are in different encoding

Hello , I think i encountered a PHP bug When my header file is in UTF-8 encoding and my index.php file is in ANSI PHP gives " headers already sent " error . Is this normal ? and if yes , can you explain why ? ...

call WSDL by PHP

Hi all, I need to use an WSDL, and call some functions. I need my request will have this format: username password I can not get any data back from server, the server can not recognize my transfer parameters. Thanks for your support. ...

YouTube API videoEntry count comments

I am trying to get the comment count for a video entry but this is giving me a count of 1 when there are no comments. Any ideas? <?php $commentFeed = $yt->getVideoCommentFeed($videoID); if ( count($commentFeed) > 0 ) { foreach ($commentFeed as $commentEntry) { // print commentEntry } }...

Java conversion to php?

Is it possible to convert this java code snippet to php? public void testBalanceReturnsToZeroOnVending() { sodaVendor.insertCoin(50); sodaVendor.insertCoin(20); sodaVendor.insertCoin(5); // The price is right! assertEquals("We have entered correct money", ...

PHP: how is an array in a foreach loop read?

We have all heard of how in a for loop, we should do this: <?php for ($i = 0, $count = count($array); $i < $c; ++$i) { // Do stuff while traversing array } ?> instead of this: <?php for ($i = 0; $i < count($array); ++$i) { // Do stuff while traversing array } ?> for performance reasons (i.e. initializing $count would've...

First date of a week

Hi, I want a First Day Of a week say I have 45th week. Now I want to have date of the first sunday of this week. Can any one suggest me how I can go about this ? Thank you ...

code for decode link address from a message body

I need a code for take the link address that be in the email message body. Now i take message body in a variable and i can print that one on the screen. Now i need to take the link contained in it. Or otherwise need a code for converting that text file in t an html format . please help for doing this ...

URL Aliasing using .htaccess

i'm having 'domainname1/folder/' .In Domainname1 i'm having a subdirectory which is a subdomain (abc.mydomain.com) of other domain. but this is referred to 'domainname1/folder/' . the thing is that i want the URL links accessing from 'domainname1/folder/' should be displayed following with sub domain like . 'domainname1/folder/' to ...

PHP: how to get last inserted ID of a table ?

I have a table, which regularly is inserted with new data. I need to get the very last ID of the table. How can I do this? Is it similar to: SELECT MAX(id) FROM table ? ...

PHP5: const vs static

In PHP5, what is the difference between using const and static? When is each appropriate? And what role does public, protected and private play - if any. ...

Consistency in $_GET

Is there a good way to keep consistency in the $_GET For example if i have a url http://www.example.com/index.php?Id=5&amp;sort=new And i want to now add a new $_GET field at the end of that so is there any way i can create a function that will keep the Id and sort and add my new var lim? So the URL Now looks like: http://www.example....

.htaccess Redirect non-WWW to WWW preserving URI string

I'm running the CodeIgniter platform, which uses .htaccess to accept URLs like http://www.mysite.com/controller/function/argument I currently use some .htaccess rewrites, namely (simplified): RewriteEngine On RewriteCond %{REQUEST_URI} !^(/index\.php|/images|/assets) RewriteRule ^(.*)$ /index.php/$1 [L] I want to add a rewrite rule...

Getting the type of mobile phone

Is there a way to get the type of mobile Phone when a phone connects to a mobi site using PHP? ...