Webmaster Forum


Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Coding Forum Problems with your code? Let's hear about it.

Lionsanime Directory   ClickBooth Network   V7N Directory

Reply
 
LinkBack Thread Tools Display Modes
Old 10-09-2004, 10:26 AM   #1 (permalink)
SVB
Inactive
 
SVB's Avatar
 
Join Date: 10-13-03
Posts: 7,481
iTrader: 0 / 0%
Latest Blog:
None

SVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest order
Send a message via Yahoo to SVB
Delphi MySQL Help Needed

Im trying to learn MySQL with Delphi. Ive got it to connect to my database fine. Now Im trying to make it validate an entered username and password to the username and password on the database.
This code is for the login button action. It compiles, but when I click login, I get an error. How do I do this? Iim not sure what way to lay out the "enteredusername.Text", if it even needs .text etc. I think I need to use "pchar" somewhere, but arent sure where. Someone help!
Code:
mysql_query(@sqlconnection, 'SELECT * FROM staff WHERE staffid = enteredusername.Text AND password= enteredpassword.Text'); sqlresult := mysql_store_result(@sqlconnection); sqlrow := mysql_fetch_row(sqlresult); if sqlrow[1] = enteredpassword.Text then //The rest of the code....

Last edited by SVB : 10-09-2004 at 10:33 AM.
SVB is offline  
Add Post to del.icio.us
Reply With Quote
Sponsored Links
SEO Hosting by HostGator  Advertise Here  Buy Blog Links
Old 10-09-2004, 10:54 AM   #2 (permalink)
Inactive
 
littleFella's Avatar
 
Join Date: 06-20-04
Location: Ontario
Posts: 3,359
iTrader: 0 / 0%
Latest Blog:
None

littleFella is a splendid one to beholdlittleFella is a splendid one to beholdlittleFella is a splendid one to beholdlittleFella is a splendid one to beholdlittleFella is a splendid one to beholdlittleFella is a splendid one to beholdlittleFella is a splendid one to beholdlittleFella is a splendid one to beholdlittleFella is a splendid one to beholdlittleFella is a splendid one to beholdlittleFella is a splendid one to behold
It looks to me like you're trying to use some sort of API or something, and it looks awfully similar to PHP way of doing things.

Aren't there any delphi components to connect to MySQL from Delphi? I thought there were. Try OpenSource components at http://www.zeoslib.net.

Having installed the components all you will have to (to mimic your code) do would be something like:

PHP Code:
mySQL.Close;
mySQL.SQL.UnPrepare;
mySQL.SQL.Prepare;
mySQL.SQL.Query.Text:='SELECT * FROM staff WHERE staffid =' enteredusername.Text+  'AND password=' enteredpassword.Text;
mySQL.SQL.Open
Traversing a dataset is done like this:

PHP Code:
SomeDataSet.First// make sure you're at the begining
while not SomeDataSet.EOF do
begin
 
// some code here such as:
 // Caption:=SomeDataSet.Fields[0].Value;
 //or 
 // Caption:=SomeDataSetFieldName.Value;
  
SomeDataSet.Next;
end

If you have an option to use any database you pick, then try Firebird, which is closer to SQL compliance than MySQL, and unlike MySQL, it is trully free, even for commercial apps.

<edit: typos in code>
littleFella is offline  
Add Post to del.icio.us
Reply With Quote
Old 10-09-2004, 12:47 PM   #3 (permalink)
SVB
Inactive
 
SVB's Avatar
 
Join Date: 10-13-03
Posts: 7,481
iTrader: 0 / 0%
Latest Blog:
None

SVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest orderSVB is a web professional of the highest order
Send a message via Yahoo to SVB
Thanks for that.
I finally got it to work by the following:

Code:
mysql_query(@sqlconnection, pchar('SELECT * FROM staff WHERE staffid = '+enteredusername.Text)); sqlresult := mysql_store_result(@sqlconnection); if sqlresult.row_count = 0 then showmessage('Username does not exist') else begin sqlrow := mysql_fetch_row(sqlresult); if sqlrow[1] = enteredpassword.Text then // then else end code here
SVB is offline  
Add Post to del.icio.us
Reply With Quote
Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum

Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Perl - MySQL Guru Needed Zap Coding Forum 0 02-13-2006 08:14 PM
PHP/MySQL Query needed for UNIX Timestamp Limit Coding Forum 1 08-15-2005 11:58 AM
VERY SIMPLE php /mysql script needed. will pay craigj Coding Forum 1 01-05-2004 09:00 PM


Sponsor Links
Get exposure! Get exposure! Find Scripts Web Hosting Directory Get exposure! SEO Blog


All times are GMT -7. The time now is 04:32 AM.
© Copyright 2008 V7 Inc