Posted by: Anil Kumar Panigrahi in: ● July 21, 2010
Recently one of my friend installed php 5.3 version in his system , and working on oscommerce project. When he trying to run the application he got some fatal errors. I want to discuss some of them and how rectify it.
1) Deprecated: Function eregi() is deprecated in C:\xampp\htdocs\sportstrack\catalog\includes\classes\language.php
To overcome this error :
in language.php at line no.90 Add this line
if (preg_match('/^(' . $value . ')(;q=[0-9]\\.[0-9])?$/i', $this->browser_languages[$i]) && isset($this->catalog_languages[$key])) { $this->language = $this->catalog_languages[$key];
Mostly we forget the passwords after few days, same thing happen in this application also. I forgot the oscommerce admin password and run this application in localhost.
Posted by: Anil Kumar Panigrahi in: ● July 13, 2010
Hi friends,
Now a days maintaining backup files very difficult with small changes in the file. Example If we taken file and backup it and done few changes in that file. After few days if we look into that file,it is difficult us to identify at which part we changed in the new file when compare to old backup file.
So, to avoid such types of difficulties we can implement SVN(Subversion).
Posted by: Anil Kumar Panigrahi in: ● July 2, 2010
Hi friends,
In this post i want to explain how to create rss feeds using php code and get the data from mysql table.
1) Connect to database:
We already discussed about how to connect database using php code.See the following code to connect database:
1 2 3 4 5 6 7 8 9 10 11 | <?php DEFINE ('DB_USER', 'root'); DEFINE ('DB_PASSWORD', 'root'); DEFINE ('DB_HOST', 'localhost'); DEFINE ('DB_NAME', 'rss'); // Make the connnection and then select the database. $dbc = @mysql_connect (DB_HOST, DB_USER, DB_PASSWORD) OR die ('Could not connect to MySQL: ' . mysql_error() ); mysql_select_db (DB_NAME) OR die ('Could not select the database: ' . mysql_error() ); ?> |
By using about code we can connect to database sucessfully.

2) Write a class to create rss feed using database
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | <?php class RSS { public function RSS() { require_once ('mysql_connect.php'); } public function GetFeed() { return $this->getDetails() . $this->getItems(); } private function dbConnect() { DEFINE ('LINK', mysql_connect (DB_HOST, DB_USER, DB_PASSWORD)); } private function getDetails() { $detailsTable = "webref_rss_details"; $this->dbConnect($detailsTable); $query = "SELECT * FROM ". $detailsTable; $result = mysql_db_query (DB_NAME, $query, LINK); while($row = mysql_fetch_array($result)) { $details = '<?xml version="1.0" encoding="ISO-8859-1" ?> <rss version="2.0"> <channel> <title>'. $row['title'] .'</title> <link>'. $row['link'] .'</link> <description>'. $row['description'] .'</description> <language>'. $row['language'] .'</language> <image> <title>'. $row['image_title'] .'</title> <url>'. $row['image_url'] .'</url> <link>'. $row['image_link'] .'</link> <width>'. $row['image_width'] .'</width> <height>'. $row['image_height'] .'</height> </image>'; } return $details; } private function getItems() { $itemsTable = "webref_rss_items"; $this->dbConnect($itemsTable); $query = "SELECT * FROM ". $itemsTable; $result = mysql_db_query (DB_NAME, $query, LINK); $items = ''; while($row = mysql_fetch_array($result)) { $items .= '<item> <title>'. $row["title"] .'</title> <link>'. $row["link"] .'</link> <description><![CDATA['. $row["description"] .']]></description> </item>'; } $items .= '</channel> </rss>'; return $items; } } ?> |
By using about code we can create a class for rss feed.
3) Create a object to class and display rss feeds.
1 2 3 4 5 6 | <?php header("Content-Type: application/xml; charset=ISO-8859-1"); include("classes/RSS.class.php"); $rss = new RSS(); echo $rss->GetFeed(); ?> |
Hope that it will be useful.
Posted by: Anil Kumar Panigrahi in: ● June 27, 2010
The following script to copy the text from remote url using php code.
<?php $regex = '/]*>(.*<\/body>/smi'; /*END config, BEGIN html*/ $data = file_get_contents($siteName) or die('Cannot read ' . $siteName); preg_match($regex, $data, $cleanData); if(!empty($cleanData)) $data = $cleanData[1]; echo $data; ?> <!-- HTML Footer Data here... -->
This is simple copy text from another site, but it will be useful for who are new to php.
Comments