473,379 Members | 1,355 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

ASP with mySQL

Hi ive created a simple asp file with a html form.. you type a username and password... press add... if your already on the database then it says
Expand|Select|Wrap|Line Numbers
  1. response.write("couldn't write name <br />")
not a problem.. however if it is a new name... it gives me errors.. could anyone please tell me how to fix this...

thanks in advanced!

steve



Expand|Select|Wrap|Line Numbers
  1. sub addUser()
  2.     if user<>"" and pass<>"" and delete="" then
  3.         mySQL = "SELECT userName FROM customers;"
  4.         objRS.Open mySQL, objConn
  5.     do until objRS.EOF
  6.         for each x in objRS.Fields
  7.         dim valueman
  8.         valueman = x.value
  9.             if user<>valueman then
  10.                 response.write("wrote: " & user & " with Pass: " & pass & " <br />")
  11.                 mySQL = "INSERT INTO customers VALUES('" & user & "','" & pass & "');"
  12.                 objRS.Open mySQL, objConn
  13.                 call callMSG(user, pass)
  14.             else
  15.                 response.write("couldn't write name <br />")
  16.             end if
  17.             if user<>"" and pass<>"" and delete<>"" then
  18.                 mySQL = "DELETE FROM customers WHERE userName='"& user &"';"
  19.                 Response.Write("User:" & user & " Has been Deleted from the System")
  20.                 objRS.Open mySQL, objConn
  21.             end if
  22.         next
  23.         objRS.MoveNext
  24.     loop
  25.     end if
  26.  
  27. end sub
Oct 19 '07 #1
3 1464
JamieHowarth0
533 Expert 512MB
Hi Steve,

Make sure that anonymous logons have modify and write permissions on your MySQL database and table - or set up a new user that your connection can then utilise to write and delete users from your DB.

Best regards,

medicineworker
Oct 19 '07 #2
hi, thans for getting back..

the code actually works to add a user and pass.. but im trying to make sure if there already is someone by that user that it doesnt add it

thanks

steve
Oct 19 '07 #3
JamieHowarth0
533 Expert 512MB
Hi steve,

Try this code and see if it works (notice comments also):

Expand|Select|Wrap|Line Numbers
  1. Sub addUser()
  2. Select Case delete '<-- Are we deleting a user?
  3. Case "" '<-- Not deleting user
  4. mySQL = "SELECT userName FROM customers WHERE userName = '" & user & "';" '<-- Try and find a user with that username already
  5. objRS.Open mySQL, objConn, 1, 1
  6. If objRS.RecordCount > 0 '<-- If we find a user with that name already... decline the user!
  7. Response.Write("Couldn't write user, username already exists.<br />")
  8. Else '<-- Add new user!
  9. mySQL = "INSERT INTO customers VALUES('" & user & "','" & pass & "');"
  10. objRS.Close
  11. objRS.Open mySQL, objConn, 2, 3
  12. Response.Write("Wrote: " & user & " with password: " & pass & " <br />")
  13. call callMSG(user, pass)
  14. End If
  15. Case Else '<-- Deleting user
  16. mySQL = "DELETE FROM customers WHERE userName='"& user &"';"
  17. objRS.Open mySQL, objConn, 2, 3
  18. Response.Write("User:" & user & " Has been Deleted from the System")
  19. End Select
  20.  
  21. End Sub
Hope it helps.

medicineworker
Oct 22 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: francescomoi | last post by:
Hi. I'm trying to build 'MySQL-python-1.2.0' on my Linux FC2: ---------------------------------- # export PATH=$PATH:/usr/local/mysql/bin/ # export mysqlclient=mysqlclient_r # python setup.py...
4
by: mikey | last post by:
Hi all, I'm having great problems trying to install the latest MySQl RPM package onto my Red Hat Linux OS. There is already MySQL v 3.0 pre-installed with the RH Linux distribution disk but I...
0
by: Yun Guan | last post by:
Hello mysql gurus, I am trying to run perl on mysql database on Red Hat box. I want to install DBI and DBD:mysql using CPAN: perl -MCPAN -e shell cpan>install DBI The above succeeded, but...
0
by: Mike Chirico | last post by:
Interesting Things to Know about MySQL Mike Chirico (mchirico@users.sourceforge.net) Copyright (GPU Free Documentation License) 2004 Last Updated: Mon Jun 7 10:37:28 EDT 2004 The latest...
2
by: Saqib Ali | last post by:
I installed mySQL and have it running.... but I think I made a mistake somewhere along the line...... I believe I did follow the instructions that were provided with the distribution at:...
1
by: Alex Hunsley | last post by:
I am trying to install the DBD::mysql perl module. However, it claims I need mysql.h: cpan> install DBD::mysql CPAN: Storable loaded ok Going to read /home/alex/.cpan/Metadata Database was...
0
by: ./Rob & | last post by:
Hi gang: I'm experiencing a problem with MySQL -- I updated MySQL from version 4.1.0 to 4.1.10 and now when I login as root it doesn't show all the databases I should have access to, nor it...
2
by: trihanhcie | last post by:
I m currently working on a Unix server with a fedora 3 as an os My current version of mysql is 3.23.58. I'd like to upgrade the version to 5.0.18. After downloading from MYSQL.COM the package on...
1
by: manish deshpande | last post by:
Hi, When i'm installing MySQL-server-standard-5.0.24a-0.rhel3.i386.rpm by the following command: rpm -i MySQL-server-standard-5.0.24a-0.rhel3.i386.rpm the following error is being shown: ...
3
by: menzies | last post by:
Hi, I"m new to this forum, but I have been trying all day to install DBD::mysql onto my Intel MacBook. I've read lots of forums pages and none have gotten me to a successful 'make test' or a...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.