jump to navigation

Returning string in a specified number of words using PHP September 22, 2006

Posted by ordinarywebguy in PHP.
4 comments

function wordTrim($str, $len){
$wordCount = 0;
$charCount = 0;

$length = strlen(strip_tags($str));
for ($i=0; $i<$length; $i++) {
if ($str[$i] == ” “) {
$wordCount++;
$charCount++;
if ($wordCount == $len)
break;
} else {
$charCount++;
} # end if
} # end for loop

$newstr = substr($str, 0, $charCount);
return $newstr;
} # end function$str = “Hello World!”;
print wordTrim($str, 1); // Will print Hello

Inserting Special Characters to MySQL using PHP September 20, 2006

Posted by ordinarywebguy in PHP.
3 comments

After reading about Character Encodings, I got a solution to one of my task:

function spEncode($string) {
return base64_encode($string);
}

function spDecode($string) {
$string = base64_decode($string);
}

/*** Inserting ***/
$MySQL = “INSERT INTO table (field) VALUES (‘”. spEncode($field) .”‘)”;
mysql_query($MySQL,$MyDB) or die(mysql_error());

/*** Retrieve **/
$MySQL = “SELECT field FROM table “;
$MyQuery = mysql_query($MySQL or die(mysql_error());
while($row = mysql_fetch_row($MyQuery)) {
$field = spDecode($row[0]);
}
print nl2br($field);

Problem solved! :)

One Stop PHP Resources and It’s Peer September 8, 2006

Posted by ordinarywebguy in Ajax, Cool Websites, Java, Javascript, MySQL, OOP, PHP, PHP Blogs, PostgreSQL, Ruby.
1 comment so far

FeedPHP is going to be the largest repository of feeds from PHP and related news sources. This one stop news source parses feeds from thousands other php website and displays the titles. As we know, MySQL, PostgreSQL, AJAX are also relevant to PHP, so FeedPHP collects feeds from those sources as well.

Visit it here: http://www.feedphp.com/

All thanks to Hasin Hayder.

MySQL Freaks Site is Down September 7, 2006

Posted by ordinarywebguy in MySQL.
add a comment

Finally, after posting in phpFreaks forum what I’ve discovered in the site MySQL Freak Site’s Vulnerability, site admins disabled the site and redirect it to http://www.phpfreaks.com/forums/index.php/board,3.0.html.

I felt that I somehow helped them with the integrity of the site. Hopefully site admins will immediately fix the vulnerability of it. The site helped me a lot both in my job and personal learnings in mysql.

I am waiting for the time that the site will be up and live again. Goodluck to MySQLFreaks.com admins.