ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 6th, 2009, 10:57 AM
galahad3 galahad3 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 83 galahad3 User rank is Sergeant (500 - 2000 Reputation Level)galahad3 User rank is Sergeant (500 - 2000 Reputation Level)galahad3 User rank is Sergeant (500 - 2000 Reputation Level)galahad3 User rank is Sergeant (500 - 2000 Reputation Level)galahad3 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 12 h 52 m 37 sec
Reputation Power: 9
Item added into database but not showing in public page

Hi, I have a problem with an ASP-based site (connecting to mySQL database) and don't really know ASP so could do with some pointers.

Basically if I add a new product via the admin area of the site, it will show in the admin area, but it won't show in the corresponding public area that queries the same table.

Code for the admin page where products are displayed is as follows:

Code:
<%'strip special charecters    so replace request.querystring of form with strip_chr(request.quesrystring("xxx")
Function strip_chr(this_string)
incoming_string=this_string
checkfor="<>?\!£$%^&*()+=-{}][:;,/" ' add ."
for i = 1 to LEN(checkfor)
incoming_string=replace(incoming_string,Mid(checkfor,i,1)," ")
next
incoming_string=replace(incoming_string,"""","")
strip_chr=trim(incoming_string)
end function
%>
<body>
<script type="text/javascript" src="../scripts/wz_tooltip.js"></script>
<center>
<div id="wrap">
    <div id="banner">
	  <!--#include file="navigation.asp"-->


	</div><!-- end banner -->
	<div id="leftcol">
	   <div id="lefttextbox">
	      
         <div id="lefttext">
           <div align="justify">
             <p class="bodycopy"><span class="bodycopy12">Edit Stock List </span><br />
               Click on the car you wish to edit <br />
  <br />
             </p>
           </div>
           <div align="left"></div>
         </div><!-- lefttext -->
      </div>
	
	</div><!-- leftcol -->
	<div id="mainpage">
	<%if Request.Querystring("no_rows")="" then
	high="455"
	elseif Request.Querystring("no_rows")="3" then
	high="675"
	else
	high="455"
	end if%>
	<%urlreq4="stock_admin.asp?carid=" & strip_chr(Request.Querystring("carid")) %>
	<iframe src="<%=urlreq4%>" width="660" height="455"  frameborder="0" scrolling="auto" allowtransparency="true"
background-color="transparent">
	</iframe>
	</div>
	<!-- mainpage -->
</div><!-- end wrap -->
</center>
</body>


And for the public view page, where the item is not showing even though it's been added:

Code:
<body>
<script type="text/javascript" src="scripts/wz_tooltip.js"></script>
<center>
<div id="wrap">
    <div id="banner">
      <!--#include file="banner_top.asp"-->
      <table width="955" border="0" cellspacing="0" cellpadding="0">
  <tr valign="middle">
    <td width="32" background=""><img src="imagesnew/spacer.gif" width="32" height="30" /></td>
    <td width="181" background="imagesnew/middle_glow.jpg" class="bodycopyboldwt" ><div align="center"><a href="cars_for_sale.asp" class="menuwt" onmouseover="Tip('Our current selection of Aston Martin cars for sale ', BGCOLOR, '#cccccc' ,WIDTH, 160, SHADOW, true, FADEIN, 300, FADEOUT, 300, CENTERMOUSE, true, OFFSETY, 20)">Aston Martin<br />
      cars for sale</a></div></td>
    <td width="61"><div align="right"><a href="index.asp" class="menuwt" onmouseover="Tip('Return to Home page', BGCOLOR, '#cccccc' ,WIDTH, 160, SHADOW, true, FADEIN, 300, FADEOUT, 300, CENTERMOUSE, true, OFFSETY, 20)">home</a>&nbsp;&nbsp;</div></td>
    <td width="16"><div align="center"><img src="imagesnew/devider.jpg"  width="5" height="30" /></div></td>
    <td width="98"><div align="center"><a href="archives.asp" class="menuwt" onmouseover="Tip('Our Archives contain details of approximately 500 Aston Martin cars ', BGCOLOR, '#cccccc' ,WIDTH, 210, SHADOW, true, FADEIN, 300, FADEOUT, 300, CENTERMOUSE, true, OFFSETY, 20)">research your<br />
          Aston Martin</a></div></td>
     
     <td width="14"><div align="center"><img src="imagesnew/devider.jpg"  width="5" height="30" /></div></td>
     <td width="98"><div align="center"><a href="model_overview.asp" class="menuwt" onmouseover="Tip('An illustrated overview of Aston Martin from 1947 to date.', BGCOLOR, '#cccccc' ,WIDTH, 210, SHADOW, true, FADEIN, 300, FADEOUT, 300, CENTERMOUSE, true, OFFSETY, 20)">
	Aston Martin<br />model overview</a></div></td>
     <td width="9"><div align="center"><img src="imagesnew/devider.jpg"  width="5" height="30" /></div></td>
    <td width="81"><div align="center"><a href="selling.asp" class="menuwt" onmouseover="Tip('How we can help you realise the best return on your Aston Martin ', BGCOLOR, '#cccccc' ,WIDTH, 207, SHADOW, true, FADEIN, 300, FADEOUT, 300, CENTERMOUSE, true, OFFSETY, 20)">selling your<br />
    Aston Martin</a></div></td>
    <td width="12"><div align="center"><img src="imagesnew/devider.jpg"  width="5" height="30" /></div></td>
    <td width="125"><div align="center"><a href="insurance_valuation.asp"class="menuwt" onmouseover="Tip('Is your Aston Martin under insured ', BGCOLOR, '#cccccc' ,WIDTH, 130, SHADOW, true, FADEIN, 300, FADEOUT, 300, CENTERMOUSE, true, OFFSETY, 20)">insurance valuation<br />of your Aston
      Martin</a></div></td>
      <td width="12"><div align="center"><img src="imagesnew/devider.jpg" width="5" height="30" /></div></td>
    <td width="37"><div align="center" ><a href="about_us.asp" class="menuwt" onmouseover="Tip('About Us ', BGCOLOR, '#cccccc' ,WIDTH, 100, SHADOW, true, FADEIN, 300, FADEOUT, 300, CENTERMOUSE, true, OFFSETY, 20)">about us</a></div></td>
      
    <td width="12"><div align="center"><img src="imagesnew/devider.jpg" width="5" height="30" /></div></td>
    <td width="37"><div align="center" ><a href="links.asp" class="menuwt" onmouseover="Tip('Useful connections ', BGCOLOR, '#cccccc' ,WIDTH, 100, SHADOW, true, FADEIN, 300, FADEOUT, 300, CENTERMOUSE, true, OFFSETY, 20)">links</a></div></td>
     <td width="12"><div align="center"><img src="imagesnew/devider.jpg" width="5" height="30" /></div></td>
    <td width="67"><div align="center" ><a href="automobilia.asp" class="menuwt" onmouseover="Tip('Users automobilia and parts ', BGCOLOR, '#cccccc' ,WIDTH, 120, SHADOW, true, FADEIN, 300, FADEOUT, 300, CENTERMOUSE, true, OFFSETY, 20)">automobilia<br />
and Parts</a></div></td>
    <td width="28">&nbsp;</td>
  </tr>
</table>

	</div><!-- end banner -->
	<div id="leftcol">
	   <div id="lefttextbox">
	      
         <div id="lefttext">
           <div align="justify">
             <p class="bodycopy"><span class="bodycopy12">Cars for Sale</span><br />
               Whilst this list gives an indication of our permanent selection, stock is constantly changing. Please click on the Model / Type for full details on individual cars. Alternatively you can contact us if you are interested in any of the vehicles listed. <br />
               Telephone (44) 01737 244567.<br />
  <br />
  <span class="bodycopy12">Looking for a particular model?</span><br />
               If you are looking for a specific vehicle - please let us know and I will contact you with any information or sellers I may have. <a href="car_wanted.asp" class="bodycopy">Click here</a> to find out more</p>
             <p class="bodycopy">&nbsp;</p>
             <p class="bodycopy"><span class="bodycopy12">Finance</span><br />
               Explore your purchasing power through flexible payment plans designed specifically for the purchase of these cars. Contact Robert Johnson of Classic & Sport Finance 08450 264242 or <a href="mailto:rob@classicandsportsfinance.com" class="bodycopy">rob@classicandsportsfinance.com</a></p>
           </div>
           <div align="left"></div>
         </div><!-- lefttext -->
      </div>
	
	</div><!-- leftcol -->
	<div id="mainpage">
	<%if Request.Querystring("no_rows")="" then
	high="455"
	elseif Request.Querystring("no_rows")="3" then
	high="675"
	else
	high="455"
	end if%>
	<iframe src="stock.asp" width="670" height="<%=high%>"  frameborder="0" scrolling="auto" allowtransparency="true"
background-color="transparent">
	</iframe>
	</div>
	<!-- mainpage -->
</div><!-- end wrap -->
</center>
</body>

Last edited by galahad3 : October 6th, 2009 at 11:46 AM.

Reply With Quote
  #2  
Old October 6th, 2009, 01:57 PM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 15th Plane (12000 - 12499 posts)
 
Join Date: Jun 2003
Posts: 12,265 Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 3 Days 10 h 10 m 34 sec
Reputation Power: 2009
Use response.write debug statements in the asp server code to check variable contents where you suspect there may be problems.
__________________
======
Doug G
======
I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain

Reply With Quote
  #3  
Old October 7th, 2009, 05:55 AM
galahad3 galahad3 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 83 galahad3 User rank is Sergeant (500 - 2000 Reputation Level)galahad3 User rank is Sergeant (500 - 2000 Reputation Level)galahad3 User rank is Sergeant (500 - 2000 Reputation Level)galahad3 User rank is Sergeant (500 - 2000 Reputation Level)galahad3 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 12 h 52 m 37 sec
Reputation Power: 9
Thanks, I've got a bit further now with an older file that displays the stock in public view, as follows:

Code:
<!--#include file="Connections/allaston.asp" -->
<%
Dim Recordset1
Dim Recordset1_numRows
Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_allaston_STRING
Recordset1.Source = "SELECT * FROM allaston.cars WHERE is_archived='N' ORDER BY Year ASC"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()
Recordset1_numRows = 0
%>
<%
Function Getpic(carno)
Dim Recordset2__MMColParam
Recordset2__MMColParam = carno
Dim Recordset2
Dim Recordset2_numRows
Set Recordset2 = Server.CreateObject("ADODB.Recordset")
Recordset2.ActiveConnection = MM_allaston_STRING
Recordset2.Source = "SELECT * FROM allaston.pictures WHERE car_id = " + Replace(Recordset2__MMColParam, "'", "''") + " ORDER BY pic_position ASC"
Recordset2.CursorType = 0
Recordset2.CursorLocation = 2
Recordset2.LockType = 1
Recordset2.Open()
Recordset2_numRows = 0
Getpic = (Recordset2.Fields.Item("pic_filename").Value)
Recordset2.Close()
Set Recordset2 = Nothing
end function
%>
<%
Dim HLooper1__numRows
HLooper1__numRows = -3
Dim HLooper1__index
HLooper1__index = 0
Recordset1_numRows = Recordset1_numRows + HLooper1__numRows
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index
Repeat1__numRows = -1
Repeat1__index = 0
Recordset1_numRows = Recordset1_numRows + Repeat1__numRows
%>
<link href="css/ALLASTON.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="scripts/mootools.js"></script> 
  <script type="text/javascript" src="scripts/reflection.js"></script>
      
   <body>
   <script type="text/javascript" src="scripts/wz_tooltip.js"></script>
 
  <table width="620" border="0">
 
  <tr>
    <td class="bodycopyboldwt" width=207><div align="center">
      <table>
   <tr><td colspan="3" class="bodycopyboldwt"><div align="center" class="menugrey">Click on the car image for full information</div></td>
   </tr>
        <%
startrw = 0
endrw = HLooper1__index
numberColumns = 3
numrows = -1
while((numrows <> 0) AND (Not Recordset1.EOF))
 startrw = endrw + 1
 endrw = endrw + numberColumns
 %>
        <tr align="center" valign="top" class="bodycopyboldwt">
          <%
While ((startrw <= endrw) AND (Not Recordset1.EOF))
%>
         <% 'check to see if pic exists
   picreq = getpic((Recordset1.Fields.Item("carid").Value))
         Set fs=Server.CreateObject("Scripting.FileSystemObject")
         'If (fs.FileExists(dirrequ)=true) Then 
            'picrequired = picreq
           'Else
            'picrequired = "blank.jpg" 
            'End If %>
   
    <td width="306"><img src="images/spacer.gif" width="200"  height="1"/>
    <a href="car_for_sale.asp?carid=<%=(Recordset1.Fields.Item("carid").Value)%>" Target="_top" onMouseOver="Tip('Click on the photo for full details of the car <%=(fs.FileExists(dirrequ)=true)%>', WIDTH, 150,  SHADOW, true, FADEIN, 300, FADEOUT, 300, OFFSETY, 40)">
    <img src="carpictures/<%=picreq%>" width="200" /></a>
    <%=(Recordset1.Fields.Item("title").Value)%>&nbsp;<%=(Recordset1.Fields.Item("carid").Value)%><br />
    <span class="bodycopyboldred">£<%=(Recordset1.Fields.Item("Price").Value)%></span>&nbsp;&nbsp;<%=(Recordset1.Fields.Item("Chassis_no").Value)%><br />
    <%=(Recordset1.Fields.Item("Transmission").Value)%>&nbsp;&nbsp;<%=(Recordset1.Fields.Item("Year").Value)%>&nbsp;&nbsp;<%=(Recordset1.Fields.Item("Steering").Value)%> hd<br />Colour: <%=(Recordset1.Fields.Item("Colour").Value)%><br />Interior: <%=(Recordset1.Fields.Item("Interior").Value)%><br />Hood: <%=(Recordset1.Fields.Item("Hood").Value)%></td>
          <%
 startrw = startrw + 1
 Recordset1.MoveNext()
 Wend
 %>
        </tr>
        <%
 numrows=numrows-1
 Wend
 %>
      </table>
    </div></td>
 
  </tr>
 
  
</table>
</body>
      <%
Recordset1.Close()
Set Recordset1 = Nothing
%>


However...

I get this error when browsing the page:

Code:
ADODB.Field error '800a0bcd' 

Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record. 

/stock2.asp, line 34 

Line 34 is this:

Getpic = (Recordset2.Fields.Item("pic_filename").Value)



I've checked Recordset2, which pulls from the allaston.pictures table, and there's definitely a field with that exact name (pic_filename) so not sure what's causing this problem?

Reply With Quote
  #4  
Old October 7th, 2009, 03:55 PM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 15th Plane (12000 - 12499 posts)
 
Join Date: Jun 2003
Posts: 12,265 Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 3 Days 10 h 10 m 34 sec
Reputation Power: 2009
The error means you have a recordset object but it's empty. Good programming practice is to always check for an empty recordset before trying to use the recordset using
Code:
if recordset.BOF and recordset.EOF Then
For troubleshooting, run the sql select in your database query tool and verify you get the proper records from the query.

Reply With Quote
  #5  
Old October 8th, 2009, 05:47 AM
galahad3 galahad3 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 83 galahad3 User rank is Sergeant (500 - 2000 Reputation Level)galahad3 User rank is Sergeant (500 - 2000 Reputation Level)galahad3 User rank is Sergeant (500 - 2000 Reputation Level)galahad3 User rank is Sergeant (500 - 2000 Reputation Level)galahad3 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 12 h 52 m 37 sec
Reputation Power: 9
Quote:
Originally Posted by Doug G
The error means you have a recordset object but it's empty. Good programming practice is to always check for an empty recordset before trying to use the recordset using
Code:
if recordset.BOF and recordset.EOF Then
For troubleshooting, run the sql select in your database query tool and verify you get the proper records from the query.


Yes, in mySQL Administrator if I run SELECT * from the table then I get all the records come up, so that looks fine.

So how can I get around this error?

Reply With Quote
  #6  
Old October 8th, 2009, 06:13 PM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 15th Plane (12000 - 12499 posts)
 
Join Date: Jun 2003
Posts: 12,265 Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level)Doug G User rank is General 15th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 3 Days 10 h 10 m 34 sec
Reputation Power: 2009
Quote:
So how can I get around this error?
You'll have to figure out why you have an empty recordset in your code. Use google to find other asp debugging techniques you can use other than response.write as I mentioned above.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > Item added into database but not showing in public page


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek