Connecting Tech Pros Worldwide Help | Site Map

Invalid use of null

  #1  
Old June 12th, 2009, 12:06 AM
Familiar Sight
 
Join Date: Jul 2006
Posts: 181
Hi, I have looked around and this seems to be a common problem when a database field is empty. I have this and none of the solutions I have seen seem to work. I tried ),"'","<") but that didnt solve anything.


Expand|Select|Wrap|Line Numbers
  1. Response.Write "<tr><td height=""30"" width=""300"" align=""left"" valign=""middle""><font size=""2"">site</font></td>"
  2. Response.Write "<td height=""30"" width=""250"" align=""left"" valign=""middle""><input type=""text"" name=""imageone"" value=""" & Replace(objOptionsAndInfo("imageone"), Chr(34), "&quot;") & """ size=""30"" maxlength=""45""></td></tr>"
If anyone has a solution that would be great.
Thanks
Richard
  #2  
Old June 12th, 2009, 08:39 AM
prabirchoudhury's Avatar
Familiar Sight
 
Join Date: May 2009
Location: Wellington, New Zealand
Posts: 152

re: Invalid use of null


1. Response.Write("html hoes here"); would be like that


Expand|Select|Wrap|Line Numbers
  1.            Response.Write("<table width=500>");
  2.             Response.Write("<tr>");
  3.             Response.Write("<td align=right>");
  4.             Response.Write("<BR>");
  5.             Response.Write(DateTime.Now.ToString());
  6.             Response.Write("</td>");
  7.             Response.Write("</tr>");
  8.             Response.Write("</table>"); 
  9.  
have a look on

Carriage Return and Response.Write Output Issue

:)
  #3  
Old June 12th, 2009, 09:06 AM
GazMathias's Avatar
Expert
 
Join Date: Oct 2008
Location: Bristol, United Kingdom
Posts: 138

re: Invalid use of null


Personally, I can't stand response.writing out html. If I have to mix content with code I always come out of vbscript and just type out the html:

Expand|Select|Wrap|Line Numbers
  1. <table>
  2.   <tr>
  3.     <th>Field One</th>
  4.     <th>Field Two</th>
  5.     <th>Field Three</th>
  6.   </tr>
  7.  
  8. <% Do While Not blah.... %>
  9.   <tr>
  10.     <td><%=rs("fieldone")%></td>
  11.     <td><%=rs("fieldtwo")%></td>
  12.     <td><%=rs("fieldtwo")%></td>
  13.   </tr>
  14. <% rs.movenext
  15. Loop %>
  16. </table>
  17.  
If you use a decent editor that highlights code well (I recommend Notepad++), there are obvious benefits.

As to your original question, check if the field isn't empty before you use replace:

Expand|Select|Wrap|Line Numbers
  1. <% If not objOptionsAndInfo("imageone") = "" then Replace(objOptionsAndInfo("imageone"), Chr(34), "&quot;") %> 
Gaz
  #4  
Old June 14th, 2009, 07:52 PM
Familiar Sight
 
Join Date: Jul 2006
Posts: 181

re: Invalid use of null


Thanks to you guys I have sorted it now.
Thanks
Richard
  #5  
Old June 15th, 2009, 09:33 PM
jhardman's Avatar
Moderator
 
Join Date: Jan 2007
Location: logan, utah
Posts: 2,686

re: Invalid use of null


Quote:
Originally Posted by GazMathias View Post
Personally, I can't stand response.writing out html. If I have to mix content with code I always come out of vbscript and just type out the html

Gaz
I agree strongly.

Jared
  #6  
Old June 17th, 2009, 05:54 PM
Expert
 
Join Date: Nov 2007
Posts: 126

re: Invalid use of null


Quote:
Originally Posted by GazMathias View Post
Personally, I can't stand response.writing out html. If I have to mix content with code I always come out of vbscript and just type out the html:
I'm not so sure on this one, personally. It's been tested that (extensive) intermingling of dynamic and non-dynamic script causes CPU overhead to increase.


Form a clean code point of view, I just use line continuations when appropriate:

Expand|Select|Wrap|Line Numbers
  1. response.write "I've got a lovely bunch " & _
  2.                       "of coconuts! Deedly, dee! " & _
  3.                       "There they are standing in a row." & _
  4.                       "<big>Big ones!</big>" & _
  5.                       "<small>Small ones!</small>"
  6.  
  7.  
Clean.
  #7  
Old June 17th, 2009, 06:16 PM
jhardman's Avatar
Moderator
 
Join Date: Jan 2007
Location: logan, utah
Posts: 2,686

re: Invalid use of null


Quote:
Originally Posted by Nicodemas View Post
I'm not so sure on this one, personally. It's been tested that intermingling dynamic and non-dynamic script causes CPU overhead to increase.

Form a clean code point of view, I just use line continuations when appropriate:

Clean.
line continuations, fine, I don't have a problem with that. I have just seen too many people trying to response.write complex HTML including escaped quote marks. They always lose count of their quotes and can't decipher the error messages.
Expand|Select|Wrap|Line Numbers
  1. response.write "<input type=""text"" value="" &      rs("myTextValue") & "" name=""myTextValue"">" & vbNewLine
Do you see where the error is? the error would be something like "Command expected".

Or they use non-strict or even non-standard HTML because they are trying to avoid using quotes. The only other solution I've liked, is to assign double quotes to a variable
Expand|Select|Wrap|Line Numbers
  1. dim q
  2. q = chr(34)
  3. response.write "<input type=" & q & "text" & q & " value=" & q & _
  4.       rs("myTextValue") & q & " name=" & q & "myTextValue" & q & ">" &_
  5.       vbNewLine
but this is much less-clean than this
Expand|Select|Wrap|Line Numbers
  1. %>
  2. <input type="text" name="myTextValue" value="<%=rs("myTextValue")%>">
  3. <%
I don't know which executes faster, but I know this last is easier to read, write and troubleshoot.

Jared
Reply


Similar Threads
Thread Thread Starter Forum Replies Last Post
Invalid use of null -- After testing for null rando1000 answers 3 May 21st, 2008 01:49 PM
Invalid use of null furneragencies answers 1 September 28th, 2007 05:18 AM
Invalid Use of Null error? Asle answers 3 September 19th, 2007 10:50 AM
IsNull runTime: Invalid Use of Null sara answers 19 November 13th, 2005 03:32 PM
Invalid use of Null headware answers 2 November 13th, 2005 05:07 AM