samaru 145 a.k.a inscissor Team Colleague

Well, this topic has been beaten to death in other forums, but I'll give it one last whirl. Here's my personal take on it, after programming in CF for 10 years. There's no easy answer.

When comparing technologies, there are some things that ARE JUST NOT quantifiable, like:

Which language is easier? (Depends on your background.)

Which is faster? (Depends on your architecture, your experience, and $$.)

Which is cheaper? (There are several CF engines, not just Adobe's, that are free.)

Which language is more scalable? (Depends on your experience.)

Which language has the best community? (There are great people in all languages, as well as ignorant people who spread FUD.)

So me telling you that ColdFusion is better for those reasons would be a disservice to you. Me saying "PHP is faster than CF" has as much merit as me saying, "chocolate is better than strawberry."

However, some things ARE quantifiable:

Which language is more talked about on the web? http://langpop.com/ , http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html

Which has more books in stores? Barnes and Noble, Amazon

Which has more jobs listed in popular job search engines? monster.com, dice.com, etc.
Which language has more tooling? (Visual Studio vs Aptana vs CFBuilder vs Eclipse, etc. and addons).

Now, while quantifiable, I don't think these make a language "better." Also, .NET and Java are supported by Microsoft's and Oracle's marketing machines. Adobe on the other hand is speculated to not support ColdFusion as heavily, since they're …

samaru 145 a.k.a inscissor Team Colleague

onclick=javascript:CheckAJAXSession($user_session,$page_name)

function CheckAJAXSession(user_session){
//AJAX call to PHP XML script to check if the user_session exists in DB
if(!result)
ExecuteAJAX(page_name);

}

function ExecuteAJAX(page_name){
//if done, then reset the value in table.
}

Yeah, that would be the idea, however, you don't have to make an extra AJAX request. You can just bundle it all under one request. So:

onclick="AjaxRequest(page_name)"
.
.

Depending on how you built your app, you probably have to pass in the page_name if you're using one PHP file to do all your AJAX processing (and you need to know which page requested it). I'm guessing you don't need to pass in a user_session into that CheckAJAXSession JS function since the session id is on the server's memory... unless that is, cookies is turned off on the browser.

The problem it might take long time what do you think?

That's OK. Hey, sometimes things like generating a report or number crunching can take long. Have a label that says it may take a while. For a better experience, when the AJAX handler is fired, show a simple progress bar (an AJAX spinner).

Also one more quick question, how can I disable a link??

You have to turn off the default click event handler, in this case it's redirecting to a new page. The simplest way is to just return false when there's a click:

onclick="return false"

or

onclick="linkClick()"

function linkClick()
{
  // whatever code you want here.
  
  // return …
samaru 145 a.k.a inscissor Team Colleague

Is your data properly encoded in XML safely? I would do a check by taking the XML document you're posting, keeping all the nodes intact, but replace all the data with simple like text. For example, replace every text node and attribute value to xxxxxxx.

Try submitting that. Also, it could be possible that your XML post is being too restrictive for your web server to handle. You could change that.

Is there a way you could post the XML doc here so we can see?

samaru 145 a.k.a inscissor Team Colleague

Please also include your HTML. Where you say it fails is early enough in the code around where you're initializing your variables. Most likely you're trying setting an undefined variable and it's throwing off.

Also, be aware that with parseInt, if the argument is invalid, it will throw a NaN, so make sure you have valid numeric strings (e.g. "45", " 56", "506x" and NOT "x45"). Another reason we need to see the HTML.

samaru 145 a.k.a inscissor Team Colleague

Assume we have one button that fires ajax request

I am not looking for a solution to disable the button because the user might click on a link <a href='javascript:function()'>link</a>

Also the user might click on others links, so it's not good solution.

Not sure I follow if you first say that the request is only triggered on button press and then you say that also a link can trigger it?

In any case, I'll assume that you want only ONE specific AJAX request per user, regardless of how they requested it, whether it's a link, button, hover, etc.

The safest way would be to mark the user with a sessionid and put it in a temp table queue in your db. If the user does another request for the same process, it checks if that sessionid task is completed, and if not, don't fire it off again. Probably even better would be if rather than you use sessionid, you use the username (if they have any), that way it covers the case where if the same user account is being used on two different browsers/machines.

Also, for the sake of usability, I would disable anything that would trigger the AJAX request. If it was a link, I would disable its default even handler, and enable it again when the AJAX request is complete.

samaru 145 a.k.a inscissor Team Colleague

Pritaeas's solution is probably the simplest.

Another option is to use the browser's offline local storage. To see what I mean, check out http://www.jstorage.info/

However, to make it "easy to use" as you say, you would have to use a framework (use the website's jStorage library), otherwise you'd have to write it from scratch and worry about browser compatibility.

samaru 145 a.k.a inscissor Team Colleague

Good start, but I think you could use a better defined data structure. How about an array of objects, like so:

// Defines an array of objects:
StudentList = [ {}, {}, {} ];

StudentList[0].age = "29";
StudentList[0].semesterHours = 12;

StudentList[1].name = "Venom";
StudentList[1].age = "32";
StudentList[1].semesterHours = 14;

StudentList[2].name = "Hobgoblin";
StudentList[2].age = "34";
StudentList[2].semesterHours = 13;

alert( StudentList[1].name );

Then you can just loop over the StudentList array (StudentList.length) and filter it out based on criteria.

samaru 145 a.k.a inscissor Team Colleague

If hielo's solution doesn't work, paste your entire web document so we can further troubleshoot.

samaru 145 a.k.a inscissor Team Colleague

Aptana Studio 2. It's great because it supports code insight and autocomplete for JavaScript and JavaScript libraries, like jQuery.

http://www.aptana.com/

You can also try Notepad++. It has code coloring but not autocomplete/code insight: http://notepad-plus-plus.org/

samaru 145 a.k.a inscissor Team Colleague

I would go with http://www.dailyrazor.com/ . Good (for what you pay anyways) hosting that supports CF with SQL Server/MySQL.

samaru 145 a.k.a inscissor Team Colleague

What's the code to your view/query? You're probably not joining correctly to get the results you want.

samaru 145 a.k.a inscissor Team Colleague

I would write a dynamic TSQL statement(s) to loop through all the sys.tables / sys.columns across the different tables using the EXCEPT clause.

You can read more about it here (which was previously discussed): http://www.daniweb.com/forums/thread271165.html

samaru 145 a.k.a inscissor Team Colleague

Easiest way to do this would be to replace the < > with HTML entities before they go in the <cfsavecontent>. Then reverse the process before using it in your outputted template.

samaru 145 a.k.a inscissor Team Colleague

Ah, I read all that for nothing! J/k.

As an aside, if you're dealing with extremely large strings, you may have to configure large character objects in your datasource in the cfadmin.

samaru 145 a.k.a inscissor Team Colleague

Is it a ColdFusion error? Or is that message being displayed with a white background? Could also be your web server crapping out. Check your web server logs and CF logs.

samaru 145 a.k.a inscissor Team Colleague

It's a server-side language and can function on the server side like Java, PHP, Perl, Python, etc. Check this out: http://en.wikipedia.org/wiki/Server-side_scripting

samaru 145 a.k.a inscissor Team Colleague
<cfset yearAhead = DateAdd( "yyyy", 1, Now() ) />

<cfset dateFormatted = DateFormat( yearAhead, "mmm-dd-yyyy" ) />

<cfoutput>
#dateFormatted#
</cfoutput>
tiny7415 commented: Good thought +1
samaru 145 a.k.a inscissor Team Colleague

Use the CGI.HTTP_REFERER variable.

<cfoutput>#CGI.HTTP_REFERER#</cfoutput>

If it returns blank, it means they got to the page directly (user was not taken to it via a URL).

samaru 145 a.k.a inscissor Team Colleague

Not sure I'm following. Do you want to remove all the attributes in the anchor tag (<a>), except the href attribute/value? Or do you want to remove whatever is inside the anchor tag (tags, text, etc.)? Confused a bit, but when I see consecutive REMatches/REReplaces, I can usually reduce it to just 1 REMatch using 1 regexp.

samaru 145 a.k.a inscissor Team Colleague

This is more of an ASP.NET question. A mod should move it.

samaru 145 a.k.a inscissor Team Colleague

1) What is the difference in handling data, between arrays and SQL.

First of all, there is no concept of arrays in SQL (Server). The closest thing I know of that can simulate an array in SQL is a varchar string that's been tokenized and delimited by a character(s). That, or I can use a table and treat that as an array.

Assuming you're *not* using a set-based language like SQL - with an array, you usually iterate through it, via some sort of loop, to get the values. You can't do a select statement with arrays. In SQL, you could use a cursor, but a select statement is more efficient. Also, arrays natively have an index and table data does not. Arrays also have the capability of being very efficient for its simplicity - you have the index and data that can store a value or a pointer/reference to some other object. In SQL Server, a table has multiple columns with different types, constraints, indexes, default values, triggers, etc. - that handle and support more complex business requirements.

2) Am I right to believe anything arrays can do, SQL can do. And SQL is more time efficient rather than messing around with arrays regardless what software language is used.

You can simulate an array data structure, yes, but it's not the most efficient way. There may be times where you'll have to iterate through via triggers to emulate the array's mannerism.

3) Why would a company …

samaru 145 a.k.a inscissor Team Colleague

Why are you getting "Procedure trClient_IOIns"? Looks like you might have a trigger in place that may be adding to the fire.

samaru 145 a.k.a inscissor Team Colleague

You create a full-text catalog for the pool of data you want to search in.

samaru 145 a.k.a inscissor Team Colleague

Not sure what you're expecting. That layout would require not only a great deal of CSS, but HTML, and JavaScript (the Windows seem to be draggable) that most likely makes AJAX calls. I don't think anyone's going to do that for you.

I suggest you search Google for Admin HTML templates and you'll find HTML/CSS/JavaScript templates you can use.

samaru 145 a.k.a inscissor Team Colleague

I'm afraid there isn't a way. I've seen this question asked time after time in various forums and blogs and the answer is no. SQL Server completely wipes your data and replaces it with the recovered backup file. Cannot be recovered via transaction logs either.

On Windows, do you have automatic recovery turned on? Maybe you can recover the last mdf/ldf's and then attach those files. If it's hosted elsewhere, perhaps they have a backup.

Good luck!

samaru 145 a.k.a inscissor Team Colleague

hey buddy i read this code of urs on one of the threads my concern is tht i need to to atore the data form each row in the table into an array..... or a srting.....
could u please help me with this???


<script type="text/javascript">
#
function showContent() {
#

#
var oTBL = document.getElementById('myTable')
#
for (var x = 0; x < oTBL.rows.length; x++) {
#
for (var y = 0; y < oTBL.rows[x].cells.length; y++) {
#
alert(oTBL.rows[x].cells[y].firstChild.data);
#
}
#
}
#
}

Paste the HTML to your table and we'll be able to better help. Do you want to do it for all the tables on the page, even if the table is used for formatting? Or is it a particular table on the page that has a set id?

samaru 145 a.k.a inscissor Team Colleague

It really depends what you mean "efficient."

XML has been around for a hell of a lot longer than JSON and its syntax has grown. The primary goal was two-fold when XML came out:

1. Way to standardize the description of data.
2. Be human readable enough so that it could be modified via a text editor.

Since it came out, it's syntax and feature set has grown. You can have attributes, namespaces, XML Schemas that define an XML document - there's standard parsing engines: XQuery, Xpath, etc. Some schemas have become mainstream, like RSS, Atom, SOAP, etc.

The drawback is of course, the more complex your data, the more text you have to use to describe it (you have to use more tags).

JSON was a way to send lighten the load. You can either do this (crude example):

<store>
<customer>
   <name>Dan</name>
   <alias>samaru</name>
</customer>
<customer>
   <name>Parker</name>
   <alias>Spider-Man</name>
</customer>
</store>

Or do:

store = {"customer1":{"name":"dan","alias":"samaru"},"customer2":{"name":"Parker", "alias":"Spider-Man"}};

Note that the right of the equal sign is JSON. Since JSON came from JavaScript, you can literally use that JSON as a Javascript object. In this case, it's being set to an object named store. That's the benefit of JSON. However, it's more cryptic to read to the naked eye then XML. Also, there aren't really any standards like there are in XML.

If you're concerned about the compatibility across systems (exchanging data and whatnot) and dealing with legacy system, then go with XML. …

samaru 145 a.k.a inscissor Team Colleague

I think certifications are helpful, but only as a supplement to experience. How many years of SQL Server do you have? A good SQL Server administrator needs a lot of hands-on experience. That being said, the exams are tricky. Many claim that it's not even fair, but they make them hard on purpose.

You'll go through multiple choice and simulations where you have to actually click on various parts of SSMS after being given a task.

The MS Books (http://www.amazon.com/MS-SQL-Server-Books/b?ie=UTF8&node=3488) work well. Nothing beats actually experience though.

Also, I suggest you get the SQL Server exam simulation from Transceder. I high recommend it.
http://www.transcender.com/certprep/microsoft/sql-server-2008.kap

If you're wondering for alternatives to certification, I suggest you check out http://canoo.com/blog/2010/06/09/it-certification-alternatives-cost-benefit-analysis/

samaru 145 a.k.a inscissor Team Colleague

just simple,
select Replace('01/Mar/2010,02/Mar/2010,03/Mar/2010,04/Mar/2010,05/Mar/2010', ',','<br />')

I believe he said a <br/> every 2 tokens. The code you posted places it after every token. He's something I quickly whipped up.

DECLARE @dateList AS VARCHAR(1000)
DECLARE @dataItem AS VARCHAR(255)
DECLARE @newList AS VARCHAR(1000)

DECLARE @token AS INT
DECLARE @count AS INT

SELECT @dateList = '01/Mar/2010,02/Mar/2010,03/Mar/2010,04/Mar/2010,05/Mar/2010',
       @dateList = @dateList + ',',
       @count    = 0,
       @newList  = ''

WHILE PATINDEX('%,%', @dateList) <> 0
BEGIN
  
  SELECT  @token = PATINDEX('%,%', @dateList),
          @dataItem = LEFT(@dateList, @token - 1),
          @dateList = STUFF(@dateList, 1, @token, null)

  IF ( @count % 2 ) = 0 AND @count > 0
  BEGIN
    SET @newList = LEFT( @newList, DATALENGTH( @newList ) - 1 ) + '<br/>'
  END  

  SET @count = @count + 1  
  SET @newList = @newList + @dataItem + ',' 
END


PRINT LEFT( @newList, DATALENGTH( @newList ) - 1 )
samaru 145 a.k.a inscissor Team Colleague

Do you want to schedule jobs that make backups? What operating system do you use?

samaru 145 a.k.a inscissor Team Colleague

Something like that might work:

UPDATE dembel

SET userid = 8908

WHERE [Name] = 'o''reily'

But before doing that you need to replace the name in ur db with double apostrophe using Replace:

Replace ("o'reily", " ' ", " '' ")

Why would he replace the data with a double apostrophe? That's changing the integrity of the data, which I don't think he wants.

samaru 145 a.k.a inscissor Team Colleague

Yeap, I think one recently came out. Just search for "coldfusion reference" and you'll find the only one. It rocks. Has tags, functions, and other stuff.

samaru 145 a.k.a inscissor Team Colleague

This looks like a composite key setup:

CREATE TABLE Dpt_tbl
	(
	Name varchar(50) NOT NULL,
	Location varchar(50) NOT NULL
	)  
GO

ALTER TABLE Dpt_tbl ADD CONSTRAINT
	PK_Dpt_tbl PRIMARY KEY CLUSTERED 
	(
	  Name,
	  Location
	) 	
GO
samaru 145 a.k.a inscissor Team Colleague

Is this the first time you try to access a link server remotely?

Are you running it with admin privileges?

samaru 145 a.k.a inscissor Team Colleague

May I ask why you find "antiquated"? ColdFusion just released a kick-ass 9.0 version. Maybe you mean as popular? As much as I like CF, it's nowhere as popular as Ruby, Python, and all the other web languages nowadays.

If you have decent programming knowledge, even if you have zero, picking up Ruby should be pretty easy. Ruby on Rails is a framework, so you'll have to learn a little bit of Ruby before going onto Rails.

samaru 145 a.k.a inscissor Team Colleague

I'm not quiet sure what your problem is. Maybe what do you mean by "drags down 60,000 odd lines." Well, another way to get the max date would be:

select top 1 stk_trans_date 
from [YOUR TABLE NAME] 
order by stk_trans_date desc

Asuming stk_trans_date is of date type. Is it?

samaru 145 a.k.a inscissor Team Colleague

Well, with EXCEPT, it would work like this. I'm using

INSERT INTO #table1
  SELECT  *  
  FROM    #table2 -- latest data table (we'll be copying from here)

  EXCEPT

  SELECT  *
  FROM    #table1 -- backup table (has old data)

So that would first check if there's new records from #table2 that are not in #table1. Then it would put those records in #table1. You'll also have to query the sys.tables system view to get all table names. I would loop through all the tables and execute that snippet code. I would consider dynamic TSQL. You can write them out manually if you don't want to, but it will depend on how many tables you have.

Also there a few issues:

1. Are you using referential integrity?

2. The tables that you're comparing - for the tables that have "new" data - is that "new" data coming from just INSERT statements? If they are "new" because of UPDATE statements, then you have to take that into account. The snippet that I show here - if you have two records from each database, different because of one column, then it'll be consider as "new" data. Not sure if this is what you want.

CompareData may let you do what you want, and its table compare is free unlimited, I believe, for the evaluation version. Double check.

Check also if you have TableDiff.exe in your directory. Not sure if that comes with Express version of SQL Server: …

samaru 145 a.k.a inscissor Team Colleague

Yeah you could use TSQL, but it could get nasty if you have dependencies like referential integrity (you'd have to consider the order of the synchronization of tables).

Look into the EXCEPT clause if you have SQL Server 2005 and above. If you got the cash, I would recommend RedGate's SQL Data Compare to automate it. The trial has a 14-day, fully functional version. It's saved my bacon many times.

samaru 145 a.k.a inscissor Team Colleague

Yeah, QoQ is very limited. If it had functions to do what you're doing, it would probably have different function names, since those are TSQL-specific.

Check out Adobe's CF docs for QoQ usage: http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=using_recordsets_7.html

samaru 145 a.k.a inscissor Team Colleague

ColdFusion also has access to its Java layer, so I would look into Java encryption and calling it from ColdFusion.

samaru 145 a.k.a inscissor Team Colleague

That is a strange one.

It's a client side error (4xx HTTP), so your request is failing due to an unauthorized HTTP request. As mentioned, CFCACHing on the client side would be my first guess.

1. Have you tried looking for the word "cache" to see if there's anything used other than cfcache for caching? A CFX tag? A Java object?

2. Are you hosting this yourself or using some shared provider? I suppose it may be theoretically possible if they sneaked in a global cfinclude on all of their customer's templates to support client caching to not drain their resources as much.

3. What page is it erroring out on? Take that page, strip away all its dependencies - basically leave it blank and refresh. Place it in your root and remove Application.cfc/cfm. If you have a blank page without any includes, no objects being created (pretty much erase dependencies), no Application scope - and you're still getting that error - it's most likely your host.

What CF version do you have? Do you have access to the CFAdmin?

samaru 145 a.k.a inscissor Team Colleague

CFDirectory returns a structure. From there, you can convert the structure to XML using a CFC that was written by Ray Camden:

http://www.coldfusionjedi.com/projects/toxml/

Hope this helps!

CFDirectory actually returns a query, not a structure. Camden's toXML CFC is still applicable though.

samaru 145 a.k.a inscissor Team Colleague

When someone mentions ColdFusion architecture, I don't think about the browser. The browser is just the recipient of the information.

When I think of architecture, I think of layers, starting with a solid foundation. In this case, it's Java. At its core, ColdFusion relies on the JVM and the Java framework, so I would mention details about that.

http://www.co.multnomah.or.us/cfdocs/Developing_ColdFusion_MX_Applications_with_CFML/intro5.html

Then I would mention its integrated services (graphics[like charting], Flash, Verity, etc.), and its APIs for integrating .NET, Java, Flash, CORBA, C++, etc.

samaru 145 a.k.a inscissor Team Colleague

The syntax

SELECT * FROM [DATABASENAME].[SCHEMA].[TABLE]

So let's say you're in the Northwind database and you wanted to query a table in the Pubs database, you would do the following:

SELECT * FROM Pubs.dbo.Authors
samaru 145 a.k.a inscissor Team Colleague

Sure. Let us know if you have problems restoring.

samaru 145 a.k.a inscissor Team Colleague

Hi, I am trying to create a website where the visitor can choose one of two languages when first arriving at the website. Then I want that choice to be saved throughout the whole visit without the visitor having to log in. I've always felt that cookies are a lame way of solving things so first I tried out always including the language choice in the url and making sure that the language choice always remained (if not the user switched it) through variables and php redirects if the choice was removed from the url. But it too felt unprofessional so I tried out storing the information in a session and it works perfectly except that I'm trying to create a script that deletes the session variable when the user leaves the site (onunload on the body doesn't work here because then it gets executed when the user wants to view another page of the site and not just when he leaves).

Maybe this is all unnecessary and I should just go with a cookie? Or does anyone have another solution?

Sessions still use cookies. That's how the session data structure in the server's memory is mapped to the user's machine. Here's more on the topic from a daniweb user: http://www.daniweb.com/forums/thread138791.html

samaru 145 a.k.a inscissor Team Colleague

Using AJAX how can I get web server time..

Make an asynchronous call. Here's the HTML with JS.

<html>
<head>
<script language="JavaScript">  
ajax = new XMLHttpRequest();
 
function ShowData()
{  
  ajax.open( "GET", "servertime.php", true );  
  ajax.onreadystatechange = function() 
  {
    if ( ajax.readyState == 4 ) 
    {      
      document.getElementById("DataPanel").innerHTML = ajax.responseText;
    }
  }    
  ajax.send(null);
}  
</script>
 
<title>hey!</title>
</head>
<body>
  <button onclick="ShowData()">Show Data</button>   
  <div id="DataPanel"></div>  
</body>
</html>

Then you'll need a server side page to display the output. Notice how I use servertime.php in the above script. This PHP page will display nothing but the time.

samaru 145 a.k.a inscissor Team Colleague

Server-side JS on the client side

What do you mean Server-side client-side JS? Isn't that like an oxymoron? Or do you mean be able to write a web application that uses JavaScript that has access to system facilities that would be exist on a server-side language?

You could write plugins for browsers, that's the extent of my knowledge. For example, there's a Firefox plugin that functions like an FTP client. I think part of Firefox plugins are written in JS. Maybe the same for Chrome. I don't know of any way though that you can write one plugin that will work on all browsers equally and that can access system facilities. Sorry.

samaru 145 a.k.a inscissor Team Colleague

Hi all,I am trying for validation using regular expression for Indian mobile number.
Simply i have tried for"^[8,9]{1}[0-9]{9}$" and some others also
but it is not working.
I want regular expression for:
10 digit mobile number
starts with 8 or 9

Based on that regexp, you must be sure that there are no characters before 8 or 9 AND no characters after the last digit, because you're using the ^ and $. Maybe try pasting the source code to your application to see what you're trying to do with regexp, to try to help you further.

samaru 145 a.k.a inscissor Team Colleague

At its core, AJAX is just making a part of the page do something else while not refreshing the entire page. So for example, you can press a button, and just the button alone would load data from the server and display it on another part of the page (maybe right above it) while not loading the entire page. This is benefit one. It uses the JavaScript XmlHttpRequest (XHR) object .

Benefit two, is that with that XHR object, you can make HTTP requests that traditional HTML pages cannot. An HTML page can make a GET or POST request (e.g. via a form). With an XHR object, you have all HTTP request methods available.

When AJAX first came out, it used just XML - the server side script (e.g. ASP page) would generate XML data and the XHR object would retrieve it. Now, you can use JSON (a native JavaScript data structure) or any form of data structure you want. So the "X" in AJAX really is any type of data structure you want to pass the data from the ASP page to the XHR object.

Here's a snippet of code if you're curious (from my site): http://www.shinylight.com/category/languages/javascript/

Some JavaScript frameworks make AJAX extremely easy to use. jQuery can make a GET request using one line of code (compared to the many in the example code from my site). Also, jQuery is part of the .NET framework (last I heard MS announcing it) and …