|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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> </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"> </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"> </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. |
|
#2
|
|||
|
|||
|
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 |
|
#3
|
|||
|
|||
|
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)%> <%=(Recordset1.Fields.Item("carid").Value)%><br />
<span class="bodycopyboldred">£<%=(Recordset1.Fields.Item("Price").Value)%></span> <%=(Recordset1.Fields.Item("Chassis_no").Value)%><br />
<%=(Recordset1.Fields.Item("Transmission").Value)%> <%=(Recordset1.Fields.Item("Year").Value)%> <%=(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? |
|
#4
|
|||
|
|||
|
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 |
|
#5
|
|||
|
|||
|
Quote:
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? |
|
#6
|
|||
|
|||
|
Quote:
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > Item added into database but not showing in public page |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|