This topic is locked

Apostrophe in edit view

4/12/2007 4:52:16 PM
ASPRunnerPro General questions
C
cgstech author

Hello all...this is my first post in this forum.

I'm actually having a rather interesting issue with my intranet site built with ASPRunner
Basically here is my issue. I have several fields in the database (MS Access Database) and when creating a new record everything works fine without issue. The problem arises when i attempt to edit a record. There are 2 Field that are just text boxes (basically a Job ID and a Job Name), but the next fields in the edit are all drop menus. Drop menu 1 is "client", and drop menu 2 and so on are based on that "clients" information (address, phone number and such) What happens is if the "client" field has an apostrophe in it, the additional fields related to the client fail to populate due to a script error. The entire system works flawlessly with the exception of the edit page if the "client" field has an apostrophe. I'm fairly new to PHP, but as with most other languages dealing with databases, i do know the "apostrophe issue" associated with the databases. Such fixes included replacing the single apostrophe with a double apostrophe and so on, which after examining the ASP files, IS being done in the functions of this process.
Other fields can (and some do) have apostrophes in them without issue, but it seems as is the "onchange" for our client variable is where the conflict lies...and i'm puzzled as to how to correct it.
I hope someone can understand the issue i'm having and maybe can offer a possible solution OTHER than removing apostrophes from the client field in the database.
Any help would be greatly appreciated...

BTW using ASPRunner 4.0
Thanks in Advance!

J
Jane 4/13/2007

Hi,
this bug was fixed in the ASPRunnerPro 4.1.

Please download and install latest update of ASPRunnerPro:

http://www.asprunner.com/files/asprunnerpro-setup.exe
If you want to use ASPRunnerPro 4.0 you can send a full set of generated ASP files to [email=support@xlinesoft.com]support@xlinesoft.com[/email] along with project file and your sample database. I'll help you to fix this issue.

C
cgstech author 4/13/2007

Unfortunately, after downloading version 4.1, none of the drop boxes populate with the correct (if any) information. Building with 4.0 works fine with the exception of the above mentioned apostrophe issue, but after building with 4.1, none of the linked drop boxes are functioning/populating correctly, and also the primary search function is not working (advanced search works fine though)
Any Ideas?

Sergey Kornilov admin 4/13/2007

Post the application you built with ASPRunnerPro 4.1 to Demo Account and send me a URL along with some instructions on reproducing issues that you have. I'll take a look and be back to you.

C
clig 4/17/2007

Unfortunately, after downloading version 4.1, none of the drop boxes populate with the correct (if any) information. Building with 4.0 works fine with the exception of the above mentioned apostrophe issue, but after building with 4.1, none of the linked drop boxes are functioning/populating correctly, and also the primary search function is not working (advanced search works fine though)

Any Ideas?


yes create a view for your drop down replacing the column with: SELECT blah, Replace(ClientName, "'", "") AS ClientName, blahblah FROM Tablename

C
cgstech author 4/24/2007

Well, I've done a little bit of research and i know a little more about what is happening. I downloaded a plug-in for Firefox called "Firebug" and its great....it shows you exactly where the script errors occur.
With that in mind, it seems as though the issue lies in the bit of code that builds the drop downs in the edit view
here is a sample of the code:

<script>
<%

BuildSecondDropdownArray "arr_Client", "SELECT [Client], [Client], [Client] FROM [Client List] " & " ORDER BY [Client]", "Client"

%>

var bLoading = true;

SetSelection('Client', 'Client', '<%=rs("Client")%>', '<%=Replace(rs("Client"),"'","\'")%>', arr_Client);

bLoading = false;
<%

BuildSecondDropdownArray "arr_Contact", "SELECT [Contact], [Contact], [Client] FROM [Client List] " & " ORDER BY [Contact]", "Client"

%>

var bLoading = true;

SetSelection('Client', 'Contact', '<%=rs("Client")%>', '<%=Replace(rs("Contact"),"'","\'")%>', arr_Contact);

bLoading = false;
<%

BuildSecondDropdownArray "arr_Street1", "SELECT [Street1], [Street1], [Client] FROM [Client List] " & " ORDER BY [Street1]", "Client"

%>

var bLoading = true;

SetSelection('Client', 'Street1', '<%=rs("Client")%>', '<%=Replace(rs("Street1"),"'","\'")%>', arr_Street1);

bLoading = false;
<%

BuildSecondDropdownArray "arr_City", "SELECT [City], [City], [Client] FROM [Client List] " & " ORDER BY [City]", "Client"

%>

var bLoading = true;

SetSelection('Client', 'City', '<%=rs("Client")%>', '<%=Replace(rs("City"),"'","\'")%>', arr_City);

bLoading = false;
<%

BuildSecondDropdownArray "arr_State", "SELECT [State], [State], [Client] FROM [Client List] " & " ORDER BY [State]", "Client"

%>

var bLoading = true;

SetSelection('Client', 'State', '<%=rs("Client")%>', '<%=Replace(rs("State"),"'","\'")%>', arr_State);

bLoading = false;
<%

BuildSecondDropdownArray "arr_Zip", "SELECT [Zip], [Zip], [Client] FROM [Client List] " & " ORDER BY [Zip]", "Client"

%>

var bLoading = true;

SetSelection('Client', 'Zip', '<%=rs("Client")%>', '<%=Replace(rs("Zip"),"'","\'")%>', arr_Zip);

bLoading = false;
<%

BuildSecondDropdownArray "arr_Phone", "SELECT [Phone], [Phone], [Client] FROM [Client List] " & " ORDER BY [Phone]", "Client"

%>

var bLoading = true;

SetSelection('Client', 'Phone', '<%=rs("Client")%>', '<%=Replace(rs("Phone"),"'","\'")%>', arr_Phone);

bLoading = false;
<%

BuildSecondDropdownArray "arr_Fax", "SELECT [Fax], [Fax], [Client] FROM [Client List] " & " ORDER BY [Fax]", "Client"

%>

var bLoading = true;

SetSelection('Client', 'Fax', '<%=rs("Client")%>', '<%=Replace(rs("Fax"),"'","\'")%>', arr_Fax);

bLoading = false;
<%

BuildSecondDropdownArray "arr_Email", "SELECT [Email], [Email], [Client] FROM [Client List] " & " ORDER BY [Email]", "Client"

%>

var bLoading = true;

SetSelection('Client', 'Email', '<%=rs("Client")%>', '<%=Replace(rs("Email"),"'","\'")%>', arr_Email);

bLoading = false;
</script>


Now according to the debug, it looks like the error is occurring within the following line:

SetSelection('Client', 'Client', '<%=rs("Client")%>', '<%=Replace(rs("Client"),"'","\'")%>', arr_Client);


The debugger says that it expects a ")" for the end of the statement, but it is surely caused by an apostrophe in the 'client' value

In the code the apostrophes are escaped by using <%=Replace(rs("Client"),"'","\'")%> but it seems as if an earlier call to this value is what is causing the error. I DID try escaping the apostrophe on earlier and later calls to the value, and although i was successful in avoiding script errors, none of the drop menus populated with the correct information.
For a little more background to the issue, let me also state that the "client" field is dependent on a "Project Name" field that is in another table. All of the Client information is in the "Client List" table, but that information dependent on the project name in the record being edited.
I could post a sample database as well as a project file, but the database i'm dealing with is kind of complex with several tens of thousands of records. To eliminate confidential information, and build working "sample" data will take me quite a while, but if i must, that is what i will do.
Hopefully the information i've posted here may help to shed a little more light on this little dilemma I'm having at the moment.
Thanks in advance!

C
clig 4/30/2007

Well, I've done a little bit of research and i know a little more about what is happening. I downloaded a plug-in for Firefox called "Firebug" and its great....it shows you exactly where the script errors occur.

With that in mind, it seems as though the issue lies in the bit of code that builds the drop downs in the edit view
here is a sample of the code:

&lt;script>
<%

BuildSecondDropdownArray "arr_Client", "SELECT [Client], [Client], [Client] FROM [Client List] " & " ORDER BY [Client]", "Client"

%>

var bLoading = true;

SetSelection('Client', 'Client', '<%=rs("Client")%>', '<%=Replace(rs("Client"),"'","\'")%>', arr_Client);

bLoading = false;
<%

BuildSecondDropdownArray "arr_Contact", "SELECT [Contact], [Contact], [Client] FROM [Client List] " & " ORDER BY [Contact]", "Client"

%>

var bLoading = true;

SetSelection('Client', 'Contact', '<%=rs("Client")%>', '<%=Replace(rs("Contact"),"'","\'")%>', arr_Contact);

bLoading = false;
<%

BuildSecondDropdownArray "arr_Street1", "SELECT [Street1], [Street1], [Client] FROM [Client List] " & " ORDER BY [Street1]", "Client"

%>

var bLoading = true;

SetSelection('Client', 'Street1', '<%=rs("Client")%>', '<%=Replace(rs("Street1"),"'","\'")%>', arr_Street1);

bLoading = false;
<%

BuildSecondDropdownArray "arr_City", "SELECT [City], [City], [Client] FROM [Client List] " & " ORDER BY [City]", "Client"

%>

var bLoading = true;

SetSelection('Client', 'City', '<%=rs("Client")%>', '<%=Replace(rs("City"),"'","\'")%>', arr_City);

bLoading = false;
<%

BuildSecondDropdownArray "arr_State", "SELECT [State], [State], [Client] FROM [Client List] " & " ORDER BY [State]", "Client"

%>

var bLoading = true;

SetSelection('Client', 'State', '<%=rs("Client")%>', '<%=Replace(rs("State"),"'","\'")%>', arr_State);

bLoading = false;
<%

BuildSecondDropdownArray "arr_Zip", "SELECT [Zip], [Zip], [Client] FROM [Client List] " & " ORDER BY [Zip]", "Client"

%>

var bLoading = true;

SetSelection('Client', 'Zip', '<%=rs("Client")%>', '<%=Replace(rs("Zip"),"'","\'")%>', arr_Zip);

bLoading = false;
<%

BuildSecondDropdownArray "arr_Phone", "SELECT [Phone], [Phone], [Client] FROM [Client List] " & " ORDER BY [Phone]", "Client"

%>

var bLoading = true;

SetSelection('Client', 'Phone', '<%=rs("Client")%>', '<%=Replace(rs("Phone"),"'","\'")%>', arr_Phone);

bLoading = false;
<%

BuildSecondDropdownArray "arr_Fax", "SELECT [Fax], [Fax], [Client] FROM [Client List] " & " ORDER BY [Fax]", "Client"

%>

var bLoading = true;

SetSelection('Client', 'Fax', '<%=rs("Client")%>', '<%=Replace(rs("Fax"),"'","\'")%>', arr_Fax);

bLoading = false;
<%

BuildSecondDropdownArray "arr_Email", "SELECT [Email], [Email], [Client] FROM [Client List] " & " ORDER BY [Email]", "Client"

%>

var bLoading = true;

SetSelection('Client', 'Email', '<%=rs("Client")%>', '<%=Replace(rs("Email"),"'","\'")%>', arr_Email);

bLoading = false;
</script>


Now according to the debug, it looks like the error is occurring within the following line:

SetSelection('Client', 'Client', '<%=rs("Client")%>', '<%=Replace(rs("Client"),"'","\'")%>', arr_Client);


The debugger says that it expects a ")" for the end of the statement, but it is surely caused by an apostrophe in the 'client' value

In the code the apostrophes are escaped by using <%=Replace(rs("Client"),"'","\'")%> but it seems as if an earlier call to this value is what is causing the error. I DID try escaping the apostrophe on earlier and later calls to the value, and although i was successful in avoiding script errors, none of the drop menus populated with the correct information.
For a little more background to the issue, let me also state that the "client" field is dependent on a "Project Name" field that is in another table. All of the Client information is in the "Client List" table, but that information dependent on the project name in the record being edited.
I could post a sample database as well as a project file, but the database i'm dealing with is kind of complex with several tens of thousands of records. To eliminate confidential information, and build working "sample" data will take me quite a while, but if i must, that is what i will do.
Hopefully the information i've posted here may help to shed a little more light on this little dilemma I'm having at the moment.
Thanks in advance!


You have to match the the dependant column in other tables with a replace as well in a view

C
cgstech author 4/30/2007

Ah...i think i finally got it!
First lets look at this code snippet from the *_edit.asp file

var bLoading = true;

SetSelection('Client', 'Contact', '<%=rs("Client")%>', '<%=Replace(rs("Contact"),"'","\'")%>', arr_Contact);

bLoading = false;



The script error that occured was getting caught in the apostrophe in the <%=rs("Client")%> variable

I was able to eliminate the error by replacing every instance of <%=rs("Client")%> with <%=Replace(rs("Client"),"'","\'")%> for each of the SetSelections. Now, for records created when the original issue was occuring, the drop lists dont repopulate automatically on page load, but if i update the record with the correct values from the drop lookup wizards, and then save, every time i re-enter the same record the information populates accurately and correctly.
I'm surprised that nobody else has encountered/solved this issue.
Hopefully this information can help anyone else with the same issue