Congratulations to AcaCandy on her 100,000th post!
There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
acer black screen blue screen boot bsod computer connection crash css dell driver drivers email error ethernet excel firefox firefox 3 game hard drive internet internet explorer itunes laptop linux malware monitor network networking nvidia outlook outlook 2003 outlook 2007 outlook express partition problem router slow software sound trojan usb video virus vista wifi windows windows vista windows xp wireless
Web Design & Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Internet & Networking > Web Design & Development >
SQL UPDATE Problem


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

Closed Thread
 
Thread Tools
bordois's Avatar
Junior Member with 9 posts.
 
Join Date: Jun 2007
Experience: Advanced
20-Jan-2008, 01:24 PM #1
SQL UPDATE Problem
Basically I am wishing to update an existing record to include image filenames

I'm using response.write to print the SQL query on screen but can't seem to see why nothing is being submitted to the database.


Heres the code below;



<%@ Language=VBScript %>

<%
' make VB declare all variables
option explicit
Dim conx ' connection object to the server
Dim sql
Dim sql2
Dim NumberOfRecords

NumberOfRecords=0

' First a variable is created to make a ADO connection to the database
set conx=server.CreateObject("adodb.connection")

' This is the OLEDB version of opening a database
conx.Provider="Microsoft.JET.OLEDB.4.0"
conx.Open Server.Mappath("database/righthere.mdb")


sql="UPDATE places SET "
sql=sql & "photo1='" & Request("photo1") & "',"
sql=sql & "photo2='" & Request("photo2") & "',"
sql=sql & "photo3='" & Request("photo3") & "',"
sql=sql & "photo4='" & Request("photo4") & "',"
sql=sql & " WHERE place_id='" & session("id_place") & "'"
on error resume next


conx.Execute(sql)

conx.close
set conx=Nothing
%>



In the HTML section of the page is the following If statement to check for added records;


<%
If (NumberOfRecords ="1") Then%>
<div class="bottom_pad">
<p align="center" class="text">
<br /><br />
<%Response.Write "Your Place of Interest was successfully added to the database.<br />This listing will be available once moderated.<br /><br />"%>
</p>
</div>
<%Else%>
<div class="bottom_pad">
<p align="center" class="text">
<br /><br />
<%Response.Write "ERROR - your listing was not successful, please try again<br /><br />" & sql%>
</p>
</div>
<%End if
%>



Here is the output onscreen once the page is processed;

ERROR - your listing was not successful, please try again

UPDATE places SET photo1='volt2.jpg',photo2='',photo3='',photo4='', WHERE place_id='13'


Any help would be much appreciated, I've spent too long trying different methods to get it working!
MMJ's Avatar
MMJ MMJ is offline
Distinguished Member with 3,248 posts.
 
Join Date: Oct 2006
20-Jan-2008, 01:37 PM #2
I don't think there is a final comma.
bordois's Avatar
Junior Member with 9 posts.
 
Join Date: Jun 2007
Experience: Advanced
20-Jan-2008, 01:41 PM #3
final comma?
After the script decided to work it appears to be a one-off as with re-testing the image filenames are not being placed into the database.

Any ideas?

Last edited by bordois : 20-Jan-2008 02:47 PM. Reason: problem back again!
MMJ's Avatar
MMJ MMJ is offline
Distinguished Member with 3,248 posts.
 
Join Date: Oct 2006
20-Jan-2008, 02:54 PM #4
Quote:
Originally Posted by bordois View Post
After the script decided to work it appears to be a one-off as with re-testing the image filenames are not being placed into the database.

Any ideas?


The final comma before the WHERE command.
bordois's Avatar
Junior Member with 9 posts.
 
Join Date: Jun 2007
Experience: Advanced
20-Jan-2008, 03:00 PM #5
Amendment
I've removed the final comma but still no sign of the image filename in the database.

Just can't understand why it worked once and now it won't


Code:
sql="UPDATE places SET "
  sql=sql & "photo1='" & Request("photo1") & "',"
  sql=sql & "photo2='" & Request("photo2") & "',"
  sql=sql & "photo3='" & Request("photo3") & "',"
  sql=sql & "photo4='" & Request("photo4") & "'"
  sql=sql & " WHERE place_id='" & session("id_place") & "'"
  on error resume next
MMJ's Avatar
MMJ MMJ is offline
Distinguished Member with 3,248 posts.
 
Join Date: Oct 2006
21-Jan-2008, 06:30 AM #6
You can try UPDATE `places`...

Doesn't ASP ahve a function that dumps the mysql error?
Closed Thread

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who help people like you solve computer problems. See our Welcome Guide to get started.



Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 01:13 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.