Invalid use of null 
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. - Response.Write "<tr><td height=""30"" width=""300"" align=""left"" valign=""middle""><font size=""2"">site</font></td>"
-
Response.Write "<td height=""30"" width=""250"" align=""left"" valign=""middle""><input type=""text"" name=""imageone"" value=""" & Replace(objOptionsAndInfo("imageone"), Chr(34), """) & """ size=""30"" maxlength=""45""></td></tr>"
If anyone has a solution that would be great.
Thanks
Richard
| 
June 12th, 2009, 08:39 AM
|  | 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 -
Response.Write("<table width=500>");
-
Response.Write("<tr>");
-
Response.Write("<td align=right>");
-
Response.Write("<BR>");
-
Response.Write(DateTime.Now.ToString());
-
Response.Write("</td>");
-
Response.Write("</tr>");
-
Response.Write("</table>");
-
have a look on Carriage Return and Response.Write Output Issue
:)
| 
June 12th, 2009, 09:06 AM
|  | 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: -
<table>
-
<tr>
-
<th>Field One</th>
-
<th>Field Two</th>
-
<th>Field Three</th>
-
</tr>
-
-
<% Do While Not blah.... %>
-
<tr>
-
<td><%=rs("fieldone")%></td>
-
<td><%=rs("fieldtwo")%></td>
-
<td><%=rs("fieldtwo")%></td>
-
</tr>
-
<% rs.movenext
-
Loop %>
-
</table>
-
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: -
<% If not objOptionsAndInfo("imageone") = "" then Replace(objOptionsAndInfo("imageone"), Chr(34), """) %>
Gaz
| 
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
| 
June 15th, 2009, 09:33 PM
|  | Moderator | | Join Date: Jan 2007 Location: logan, utah
Posts: 2,686
| | | re: Invalid use of null Quote:
Originally Posted by GazMathias 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
| 
June 17th, 2009, 05:54 PM
| | Expert | | Join Date: Nov 2007
Posts: 126
| | | re: Invalid use of null Quote:
Originally Posted by GazMathias 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: -
response.write "I've got a lovely bunch " & _
-
"of coconuts! Deedly, dee! " & _
-
"There they are standing in a row." & _
-
"<big>Big ones!</big>" & _
-
"<small>Small ones!</small>"
-
-
Clean.
| 
June 17th, 2009, 06:16 PM
|  | Moderator | | Join Date: Jan 2007 Location: logan, utah
Posts: 2,686
| | | re: Invalid use of null Quote:
Originally Posted by Nicodemas 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. - 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 - dim q
-
q = chr(34)
-
response.write "<input type=" & q & "text" & q & " value=" & q & _
-
rs("myTextValue") & q & " name=" & q & "myTextValue" & q & ">" &_
-
vbNewLine
but this is much less-clean than this -
%>
-
<input type="text" name="myTextValue" value="<%=rs("myTextValue")%>">
-
<%
I don't know which executes faster, but I know this last is easier to read, write and troubleshoot.
Jared
|  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 225,662 network members.
|