CFF KB - Carrz-Fox-Fire Promotions Knowledge Base
CFF KB is all about 1 thing: The Sharing of Knowledge and the Power we gain from it.Knowledge Base
- Breadrumbs:
Convert PHP to ASP Classic - Special Characters pt.1 (Facebook Comment Time Sent)
- Article ID:
125 - Date Created
Monday, March 28, 2011 - Last Updated
Monday, March 28, 2011 - This Article Has been Viewed
2566 times - Short Desc
The articles here are to help people convert PHP scripting language over to ASP Classic. - Details
This article will focus on the different Characters that PHP uses and what the equivalent is in ASP Classic and how to re-write the code to work in your ASP Classic projects.
Be sure to look at the bottom for the Related articles, so you can continue in these lessons on learning the process. - Recreate Issue
To recreate the issue:
<?php
$days2 = floor($rows['CommentTimeSpent'] / (60 * 60 * 24));
$remainder = $rows['CommentTimeSpent'] % (60 * 60 * 24);
$hours = floor($remainder / (60 * 60));
$remainder = $remainder % (60 * 60);
$minutes = floor($remainder / 60);
$seconds = $remainder % 60;
?>
This code will take a date and match it to the timestamp it was presented to the database.
This code is similar to what Facebook uses on the member left comments.
First lets look at what the code is doing.
#1: The opening and closing Brackets in PHP
<?php
// Your data information goes here
?>
#2: php $
This represents a Variable, so if you have
$days2
Then you will be able to use the days2 within your code, as you have created a value for it here: $days2 = floor($rows['CommentTimeSpent'] / (60 * 60 * 24));
So this gets the Value and displays its information to the page.
#3: php %
This is a modulus function
#4: floor()
This will convert decimal to an integer value. - Resolve Issue
To resolve this issue:
Converting the PHP to ASP Classic
<%
dim days2
dim remainder
dim hours
dim minutes
dim seconds
days2 = int(rsProCom("timestamp") / (60 * 60 * 24))
remainder = rsProCom("timestamp") mod (60 * 60 * 24)
hours = int(remainder / (60 * 60))
remainder = remainder mod (60 * 60)
minutes = int(remainder / (60))
seconds = remainder mod (60)
%>
(We have not implemented the PHP FLOOR function in this example, sorry)
#1: The opening and closing Brackets in ASP
<%
' Your data information goes here
%>
#2: ASP DIM
The DIM is used to set a Variable to be used, ASP Classic uses the DIM instead of the PHP $
#3: ASP mod
This is a modulus function
#4: int()
This is the equivalent of the floor() values, of which converts decimal to an integer value.
--------
Related Articles
Convert PHP to ASP Classic - Special Characters pt.2 (Facebook Comment Time Sent)«
Share With Friends (Updated 6-8-2010)
Recent Articles
All Topics
- Coming Soon - Knowledge Exchange
Trending Articles
- Microsoft VBScript runtime error '800a0046' Permission denied FileSystemObject 24695
- Microsoft OLE DB Provider for SQL Server error '80040e57' String or binary data would be truncated. or The field is too small to accept the amount of data you attempted to add. Try inserting or pasting less data. 21297
- ADODB.Parameters error '800a0e7c' Parameter object is improperly defined 19544
- After Effects warning: Audio conforming failed for the following file .cfa. Perhaps due to disk space 17785
- The backup set holds a backup of a database other than the existing 16825