Google Answers Logo
View Question
 
Q: Unterminated String Constant: Need help debugging ( Answered 5 out of 5 stars,   0 Comments )
Question  
Subject: Unterminated String Constant: Need help debugging
Category: Computers > Internet
Asked by: respree-ga
List Price: $20.00
Posted: 27 Nov 2002 09:11 PST
Expires: 27 Dec 2002 09:11 PST
Question ID: 115485
Greetings Researchers:

I am getting an error on my search form found on the link below and
need help fixing it.

http://www.respree.com/cgi-bin/SoftCart.exe/scstore/sitepages/formtest2.html?E+scstore
(C&P URL if too long and it breaks)

My browser IE 6.0 tells me that there is an error here - "unterminated
string constant," which appears to mean that I am missing a quote (")
somewhere.  Not being a programmer, I don't know where to look for the
missing quote.

Additional information:  I have stripped this page down to the most
basic of elements to eliminate the possibility of the error being in
other places. There are three elements remaining (on formtest2.html).

1. A javascript which kicks off my shopping cart program
(SoftCart.exe)
2. The actual form itself
3. Pressing "go" activites a perl program that is my search engine
querying a MYSQL database (pdbsearch.pl).  For security reasons, I
can't post the code to our search program on this message but will
e-mail it to you, it that is where the problem lies.

The specific error message in IE reads:

Problems with this Web page might prevent it from being display
properly or functioning properly.  IN the future, you can display this
mesage by double-clicking the warning icon displayed in the status
bar.

Line: 215
Char: 27
Error: Unterminated string constant
Code: 0
URL: http://www.respree.com/cgi-gin/SoftCart.exe/cgi-bin/pdbsearch.pl?U+scstore+mkhg7352ffa7bca7+mkhg7352ffa7bca7

I would appreciate any help and comments. Thank you in advance.

My e-mail address is gsaito@respree.com.

Clarification of Question by respree-ga on 27 Nov 2002 10:39 PST
Forgive me.  I've been playing around with it and have determined
where the problem lies, but still don't know the nature of the problem
(if that makes sense).  Our pdbsearch.pl script calls to a page called
sresults.html to display its results on.  On the page results page,
there is an identical search box with the following syntax.

This works:
<FORM STYLE="margin-bottom:0;"
ACTION="USERPROG#/cgi-bin/pdbsearch.pl?%%softcart.sessionid%%"
METHOD="POST">
<DIV ALIGN="left"> 
<INPUT TYPE="hidden" NAME="addtocart_page"
VALUE="/scstore/scpages/showcart.html">
<INPUT TYPE="hidden" NAME="results_page"
VALUE="/../pagegen/sresults.html">
<INPUT TYPE="hidden" NAME="max_results" VALUE="12">
<input type="text" size="15" name="Keywords">
<INPUT TYPE="image" SRC="/scstore/images/btn-go3.gif" HEIGHT="14"
WIDTH="21" ALIGN="MIDDLE" NAME="image">
</DIV>
</FORM>

This is what is creating the problem:

If I substitute:

<INPUT TYPE="text" SIZE="15" NAME="keywords" VALUE="Search Products"
onClick="if(this.value=='Search Products')this.value=''"  
onBlur="if(this.value=='')this.value='Search Products'">

in place of:
<input type="text" size="15" name="Keywords">

in the form above (from the search results page, I get the error).

Its a little strange, but the first syntax works on all pages, except
for the search results page.
Answer  
Subject: Re: Unterminated String Constant: Need help debugging
Answered By: theta-ga on 27 Nov 2002 11:09 PST
Rated:5 out of 5 stars
 
Hi respree-ga,
     The error is not in your form, but in the results page that is
generated when I enter the search term 'monet' in the form and press
enter.
     In the results page, which shows the results for the search term
'monet', you have a search box at the upper-left corner. it is in the
code for this search box, that the error occurs.
     The code for the form appears in the file as follows :
==========HTML Code==================
213 |<INPUT  SIZE="15"    
214 |
215 |onClick="if(this. Products')this.  
216 |
217 |onBlur="if(this. Products'" TYPE="text" NAME="keywords">
==========End HTML======================
As you can see, line number 215 contains the JavaScript onclick event
and the character 27 is the quote(') character. The problem here is
that both the onclick event and the onblur event contain incomplete
Javascript code.
 Also, you can see that the starting doublequote(") in the onclick
event is NOT followed by the ending doublequote(") character.
Its looks to me that these are remenants of some JavaScript that you
missed removing from the code for the page.
I checked out the code for the search form on the initial page at
( http://www.respree.com/cgi-bin/SoftCart.exe/scstore/sitepages/formtest2.html?E+scstore
).
This page does not show any error. The HTML code for the form contains
the following code :
==========HTML Code==================
<input type="text" size="10" name="Keywords">
==========End HTML======================

As you can see, the INPUT tag here does not contain the onclick and
the onBlur events.
So, you have two options :
 1) Remove the onClick and onBlur elements from the INPUT tag on the
results page.    --OR--
 2) Insert valid Javascript in place of the incomplete one currently
in the onClick and onBlur events.

I assume that you are generating the HTML page dynamically using some
sort of a template file for the HTML. In this case, you will have to
modify the HTML code in this template file in order to generate the
correct pages.

Hope this helps.
If you need any clarifications, just ask!
:)

Clarification of Answer by theta-ga on 27 Nov 2002 11:38 PST
Hi respree-ga, 
  Noticed your clarification after I posted the answer. As you can
see, the problem was just what my answer specified.However the code
you posted as the one for the search box in your html file, does not
match with the code I got with the initial results page that contained
the error. That page contained the following code :
==========HTML Code================== 
<FORM STYLE="margin-bottom:0;"
ACTION="/cgi-bin/SoftCart.exe/cgi-bin/pdbsearch.pl?U+scstore+cbwx8458ffe6abe6+cbwx8458ffe6abe6"
METHOD="POST">
<DIV ALIGN="left">
<INPUT    TYPE="hidden" NAME="addtocart_page"
VALUE="/scstore/scpages/showcart.html">
<INPUT    TYPE="hidden" NAME="results_page"
VALUE="/../pagegen/sresults.html">
<INPUT    TYPE="hidden" NAME="max_results" VALUE="12">
<INPUT  SIZE="15"    
onClick="if(this. Products')this.  
onBlur="if(this. Products'" TYPE="text" NAME="keywords">
<INPUT  SRC="/scstore/images/btn-go3.gif" HEIGHT="14" WIDTH="21"
ALIGN="MIDDLE"  TYPE="image" NAME="image">
<!-- END HEADER -->
<!-- Search results will be inserted below this line -->
<!-- BEGIN FOOTNOTE -->
</DIV>
</FORM>
==========End HTML====================== 
  The onClick and onBlur elements contained incomplete(and hence
invalid) Javascript. The starting singlequote(') had no corresponding
ending singlequote('), and this was causing Internet Explorer to give
you the 'Unterminated String Constant' error. Now that you have
removed these elements, the error is gone.
 The above code differs from the code you say you specified for the
line, which is :
  <INPUT TYPE="text" SIZE="15" NAME="keywords" VALUE="Search Products"
onClick="if(this.value=='Search Products')this.value=''"   
onBlur="if(this.value=='')this.value='Search Products'"> 

 The HTML I got, was missing the VALUE="Search Products" tag and also
the parts parts of the Javascript code that contained the terms
[value] and [Search] .
 This leads me to believe that the problem is most likely with the
Perl script you are using to insert the search results into the page.
It appears that the script replaces occurrances of the above terms in
the page, including the occurrances in the HTML code, leading to the
invalid Javascript.
 Now that you know what you are looking for, it should be easy for you
to find the offending piece of code.

Hope this helps.
If you need any clarifications, just ask!
:)

Request for Answer Clarification by respree-ga on 27 Nov 2002 11:42 PST
Thank you for your answer.  You are correct in your assumption that
the search results page is dynamically generated.

I've gone back and checked my HTML on the search "results" page, and
verified the actual file (as opposed to the dynamically generated html
page it produces) has the following.

<INPUT TYPE="text" size="15" name="keywords" value="Search Products"
onclick="if(this.value=='Search')this.value=''"  
onblur="if(this.value=='')this.value='Search'">

but for some reason, when it displays the results, you are correct and
the syntax gets cut off (as described in your response).  Do you know
the correct syntax to the above HTML to prevent this from happening? 
I'd prefer to use this solution, if possible.  I've tried flip
flopping the single quotes and double quotes, but that didn't seem to
help. Thanks again.

Clarification of Answer by theta-ga on 27 Nov 2002 11:52 PST
Hi respree-ga,
   Did you check out your Perl script, as outlined in my clarification above ?

Request for Answer Clarification by respree-ga on 27 Nov 2002 12:06 PST
My fault and apologies.  I should have read your answer a little more
carefully.  Thank you.

Clarification of Answer by theta-ga on 27 Nov 2002 12:11 PST
Glad to be of help!
:)
respree-ga rated this answer:5 out of 5 stars
Excellent work.  Thorough and professional.  Thanks again!

Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy