WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
Internet Security Software
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Is_serialized() before passing variables to unserialize()
Categories : PHP, Serialize Click here to Update Your Picture
Ben Yacoub Hatem
Date : Mar 12th 2005
Grade : 2 of 5 (graded 3 times)
Viewed : 7538
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Ben Yacoub Hatem
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

Some of you will find this problem, that unserialize return error on data that haven't been serialized. So this function will help to keep your code clean :

<?php
/**
* check if a data is serialized or not
*
* @param mixed $data    variable to check
* @return boolean
*/
function is_serialized($data){
    if (
trim($data) == "") {
        return
false;
    }
    if (
preg_match("/^(i|s|a|o|d)(.*);/si",$data)) {
        return
true;
    }
    return
false;
}
?>


Sample :
<?php
if (is_serialized($data))
 
$undata = unserialize($data);
?>



Query2Report : Generating Html, Pdf and Csv Reports from SQL Query
Categories : PHP, PHP, HTML, PDF, Excel
Objects to XML Serializer/Unserializer
Categories : PHP, PHP Classes, DOM XML, Serialize
Three Cool Classes and One Trick
Categories : PHP, PHP Classes, Graphics, Email
Get the correct extension and MIME types of an image, even when the filename is incorrect.
Categories : PHP, Filesystem, General SQL
COM Support in PHP
Categories : PHP, COM
phpMyAdmin is a free software tool written in PHP intended to handle the administration of MySQL over the World Wide Web.
Categories : Databases, MySQL, Complete Programs, PHP
Class TStringList include some metods from class TStringList implemented in INPRISE/BORLAND-DELPHI
Categories : PHP Classes, PHP, Strings
Print out array key => value in colored HTML
Categories : PHP, Arrays, HTML and PHP
Get the self URL of current page
Categories : PHP, URLs, Beginner Guides
Selecting a random line from a text file
Categories : PHP, Filesystem, Arrays, Beginner Guides
CALENDAR - easy calendar-navigation with PHP
Categories : PHP, Date Time, HTML and PHP, Calendar
Persistent connections - General information.
Categories : General SQL, PHP, Databases
Simple graphic clock/watch generation using gd library.
Categories : Graphics, Date Time, PHP
Email a user with out exposing email address
Categories : PHP, Databases, MySQL, Email
Count how many weeks in the month have a specified day, such as Mon, Tue, etc. Var avail - number of days - first day name of the month, occurrences of Sun, occurrences of Mon, etc. Allows you to calculate number of working hours exclude Holidays.
Categories : Calendar, Date Time, PHP, Databases, MySQL