Serialize this - Saving Objects in PHP

Written by Kevin Davies


When building my website "Crossword Heaven" I came across a problem. I created a PHP object called "crossword" but needed to saverepparttar information inrepparttar 105975 object to a database. Now considering that this object contained a lot of information this was not an easy thing to do. Or was it?

The answer: serialize().

Whatrepparttar 105976 serialize() function does is take something like an array or object and converts it into a string that can be stored in a database. All I had to do so that I could saverepparttar 105977 crossword object is something like "serialize($crossword)." Easy! Some words of warning though. If you're using a version of PHP less than version 4 watch out because only properties get saved, not methods.

Here's a peek atrepparttar 105978 actual code:

$data = addslashes(serialize($crossword)); $name=""; if(isset($xwordInfo['xword_name'])){ $name = $xwordInfo['xword_name']; } $today = date('Y-m-d H-i-s'); $sql = "INSERT INTO `xword` ( `xword_id` , `xword_obj` , `xword_name`, `xword_owner`, `xword_width`, `xword_height`,`xword_date`) VALUES ('', '" . $data . "', '$name', '$owner', '$width', '$height', '$today');";

And here'srepparttar 105979 SQL to createrepparttar 105980 table 'xword':

CREATE TABLE `xword` ( `xword_id` int(11) NOT NULL auto_increment, `xword_obj` blob NOT NULL, `xword_name` varchar(100) NOT NULL default '', `xword_owner` varchar(100) NOT NULL default '', `xword_width` int(11) NOT NULL default '0', `xword_height` int(11) NOT NULL default '0', `xword_date` datetime NOT NULL default '0000-00-00 00:00:00', PRIMARY KEY (`xword_id`) ) TYPE=MyISAM AUTO_INCREMENT=1 ;

Got Traffic?

Written by Kevin Davies


Here's what your website must have to get lots of traffic - links pointing to your site. The more you have,repparttar more traffic you get.

But how do you get links pointing to your site? Well you could email webmasters and ask them to put a link on their site (reciprocal links). But that's rather slow. You need something that will get other people link to your site.

How do you get other people linking to your site? Here are some ideas:

Content

People want content. If your site has lots of good fresh content try providing free content feeds. You get links back to your site, and they get free updated content from your site.

Articles

Write good quality and useful articles and put a link to your site atrepparttar 105974 bottom. Allow people to freely publish them. The better and more usefulrepparttar 105975 articlerepparttar 105976 more people will publish it andrepparttar 105977 more links back to your site you will have.

Services

For example on my website Crossword Heaven (http://www.crosswordheaven.com) I have a service where webmasters can add a crossword to their site. On my site PerkyPup.com (http://www.perkypup.com) I provide quotes that other webmasters can link to by means of a dynamic image.

Cont'd on page 2 ==>
 
ImproveHomeLife.com © 2005
Terms of Use