PHP Script Timeout

Article Source: PHP Script Timeout.

PHP Script Timeout

If you’ve been having trouble with your script, and you cannot seem to figure out why your scripts just stop randomly at random times especially while reading large file… Try the following:
PHP: set_time_limit

void set_time_limit ( int $seconds )

Where it limits the maximum execution time.

When called, set_time_limit() restarts the timeout counter from zero. In other words, if the timeout is the default 30 seconds, and 25 seconds into script execution a call such as set_time_limit(20) is made, the script will run for a total of 45 seconds before timing out.

Note: This

May 20th, 2012 by codetopr in PHP | No Comments

Download Script in PHP

Article Source: Download Script in PHP.

Download Script in PHP

There comes a time that you need to offer some of your website’s content for downloading (i.e. most sites commonly offer downloads of PDF and MP3 files). You would want to to set up your download system so that it could perform certain tasks or give you certain information like how often certain files have been downloaded, etc. In this post we will share with you some PHP scripts that accomplishes this and more.
PHP Script that can be used to manage the download process:
To prevent user to download the
May 20th, 2012 by codetopr in PHP | No Comments

Twitter PHP Script

Article Source: Twitter PHP Script.

Twitter PHP Script. List of some commonly used and very useful code snippets to interact with Twitter in your web development projects.
Get the number of follower in full text:
It is always cool to display how many followers you have. To do so, simply use the short code snippet below.

<?php
$xml=file_get_contents(‘http://twitter.com/users/show.xml?screen_name=catswhocode’);
if (preg_match(‘/followers_count>(.*)</’,$xml,$match)!=0) {
$tw['count'] = $match[1];
}
echo $tw['count'];
?>

Autofollow script:
This code allow you to automatically follow user who has tweet about a specific term.

<?php
// Twitter Auto-follow Script by Dave Stevens – http://davestevens.co.uk

$user = "";
$pass = "";

$term = "";

$userApiUrl = "http://twitter.com/statuses/friends.json";

$ch = curl_init($userApiUrl);
curl_setopt($ch, CURLOPT_USERPWD, $user.":".$pass);
curl_setopt($ch, CURLOPT_RETURNTRANSFER

May 20th, 2012 by codetopr in PHP | No Comments

Facebook PHP Script

Article Source: Facebook PHP Script.

In this post is a list of most commonly used Facebook PHP Scripts. From Facebook PHP script that will communicate to the Facebook API and retrieve very basic user information to show Facebook PHP Script error messages.
Facebook PHP script to save user information to MySQL database and automatically publish to Wall:
This script can automatically collect user information (i.e. e-mail, name, birthday or picture etc.) and save to MySQL database. It also automatically publish posts to users Wall.

<?php

session_start();

if (!empty($_SESSION)) {
header("Location: home.php");
}
mysql_connect(‘localhost’, ‘username’, ‘password’);
mysql_select_db(‘dbname’);

# require library
require("facebook.php");

# Creating the facebook object
$facebook = new Facebook(array(
‘appId’

May 20th, 2012 by codetopr in PHP | No Comments

What is a PHP Script?

Article Source: What is a PHP Script?.

PHP or PHP: Hypertext Preprocessor is a general-purpose server-side scripting language originally designed for Web development to produce dynamic Web pages. It is one of the first developed server-side scripting languages to be embedded into an HTML source document, rather than calling an external file to process data. (wiki)

Even though PHP is much younger than other languages, it was established as the leading website programming language.

What do PHP code look like?

It is a rather simple language and most of its syntax is borrowed from C except for dealing with the types

May 20th, 2012 by codetopr in PHP | No Comments

PHP Array to String

Article Source: PHP Array to String.

PHP array to string. Sometimes data arrive in array which has to be convert into string, in this situation we can use implode() function which is used to convert the array into string.
One-Dimensional Arrays to String
Use the implode() function:

$array = array(‘lastname’, ‘email’, ‘phone’);
$comma_separated = implode(",", $array);

Or the var_export function:

return var_export($arr);

Multi-Dimensional Arrays to String

This code:

return implode(‘,’, $arr);

Results in this:

8 Array to string conversion
8 Array to string conversion
8 Array to string conversion
Array,Array,Array

Use this function:

$arr = array (…your array…);
foreach($arr AS $i => $v)
{
$arrSize = sizeOf($arr[$i]);
if ($arrSize > 0)
{
$str .= ‘<strong>’ . ucfirst($i) . ‘:</strong&gt

May 20th, 2012 by codetopr in PHP | No Comments

TortoiseSVN Turn of Merge

Article Source: TortoiseSVN Turn of Merge.

TortoiseSVN Turn of Merge. Here is a trick for TortoiseSVN:

How to turn off “auto-merge” in Subversion is to set SVN external diff tool to a program that will constantly fail. If external diff program fails, SVN concludes that conflict is unresolvable and wouldn’t merge it.

svn –diff-cmd=/bin/false

A good choice for the new mime-type would be:

application/octet-stream

Which just means a general binary type file.

To set the Subversion tag of a file using TortoiseSVN:

1. Right-click on the file and select properties,
2. Select the Subversion tab and enter the tag.

This picture illustrates the last part:
May 20th, 2012 by codetopr in PHP | No Comments

PHP Uppercase Every First Character in Array

Article Source: PHP Uppercase Every First Character in Array.

PHP Uppercase Every First Character in Array

A simple code to make every first character uppercase in a string, even they are separated by hyphen.
ucwords

string ucwords ( string $str )

Returns a string with the first character of each word in str capitalized, if that character is alphabetic.

Examples:
ucwords()

<?php
$foo = ‘the quick brown fox’;
$foo = ucwords($foo); // The Quick Brown Fox

$bar = ‘THE QUICK BROWN FOX’;
$bar = ucwords($bar); // THE QUICK BROWN FOX
$bar = ucwords(strtolower($bar)); // The Quick Brown Fox
?>

Hyphenated name:
i.e. donzé pierre-yves => Donzé Pierre-Yves

<?php

$str = "donzé pierre-yves";
echo ucwordsHyphen($str)… Continue reading

May 20th, 2012 by codetopr in PHP | No Comments

PHP Strip Table Name from MySQL Query

Article Source: PHP Strip Table Name from MySQL Query.

PHP Strip Table Name from MySQL Query

There comes a time that you need to rename a table in MySQL. You either run an SQL query to do this or do it with phpMyAdmin if you don’t want to bother remembering the SQL to do so.

RENAME TABLE tbl_name TO new_tbl_name
[, tbl_name2 TO new_tbl_name2] …

This statement renames one or more tables.

Example:
The example SQL below renames the MySQL table tablename to tablename_renamed:

RENAME TABLE tablename TO tablename_renamed

Renaming a MySQL table with phpMyAdmin:
Select the database then table, and click the “Operations” tab. Then
May 20th, 2012 by codetopr in PHP | No Comments

PHP Backend Joomla Form Validation

Article Source: PHP Backend Joomla Form Validation.

PHP Backend Joomla Form Validation

Form validation working on the input form in the front-end, but not working in the backend. Either doesn’t work or the form submits when it is not meant to.
You might have to change the toolbar buttons…

Put something like this above your code:

$html=’<a class="toolbar" class="button validate" type="submit" onclick="javascript: return myValidate(adminForm);" href="#">
<span title="Apply" class="icon-32-apply"></span>Apply</a>’;

JToolBarHelper::title(JTEXT::_(‘Edit Placement List’),’sections.png’);
$bar = & JToolBar::getInstance(‘toolbar’);
$bar->appendButton( ‘Custom’, $html);

Or.. instead of usual script, replace it with the script:

<script language="javascript" type="text/javascript">
<!–
function submitbutton(pressbutton) {
var form = document.adminForm;
if (pressbutton == ‘cancelemployer’) {
document.adminForm.task.value = pressbutton;
form.submit()

May 20th, 2012 by codetopr in PHP | No Comments

Web http://codetopreload.com

Premium Wordpress Plugin