Raised This Month: $51 Target: $400
 12% 

How to find when a line doesn't exist in a SQL DB


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
allenwr
Veteran Member
Join Date: Jan 2006
Location: The place where the karm
Old 01-28-2009 , 22:29   How to find when a line doesn't exist in a SQL DB
Reply With Quote #1

Everytime I run the script on my server, when I join and check the server console, it returns everything is ok, even when the steam id isnt in the table.

I need help finding when the script doesn't find a row containing the steam id.

this was my source of info. http://wiki.alliedmods.net/SQL_(SourceMod_Scripting)

PHP Code:
public OnClientPutInServer (client) {
    
decl String:authid[32]
    
GetClientAuthString(clientauthidsizeof(authid))
    new 
String:query1format[255]
    
Format(query1formatsizeof(query1format), "SELECT * FROM points WHERE Steam_ID = '%s'",authid)
    new 
Handle:query1 SQL_Query(dbquery1format)
    if(
query1 == INVALID_HANDLE) {
        
PrintToServer("Failed to get steam id, %s",authid)
    } else {
        
PrintToServer("Everything is OK")
    }
    
CloseHandle(query1)

__________________
Don't ever place an order with Vee Servers. This is why.
allenwr is offline
Send a message via ICQ to allenwr Send a message via Yahoo to allenwr
pRED*
Join Date: Dec 2006
Old 01-29-2009 , 00:31   Re: How to find when a line doesn't exist in a SQL DB
Reply With Quote #2

http://wiki.alliedmods.net/SQL_(Sour...essing_Results
pRED* is offline
allenwr
Veteran Member
Join Date: Jan 2006
Location: The place where the karm
Old 01-29-2009 , 01:16   Re: How to find when a line doesn't exist in a SQL DB
Reply With Quote #3

I am not trying to be dumb, but I have already read that page. I haven't a clue on how to find out when zero info is returned. INVALID_HANDLE isn't being returned and then goes and does they second half of the script.
__________________
Don't ever place an order with Vee Servers. This is why.
allenwr is offline
Send a message via ICQ to allenwr Send a message via Yahoo to allenwr
pRED*
Join Date: Dec 2006
Old 01-29-2009 , 01:35   Re: How to find when a line doesn't exist in a SQL DB
Reply With Quote #4

SQL_FetchRow(query)
pRED* is offline
SirLamer
Senior Member
Join Date: Oct 2008
Old 01-30-2009 , 11:46   Re: How to find when a line doesn't exist in a SQL DB
Reply With Quote #5

So what pRED means is that you use SQL_FetchRow to begin browsing the query results. The function returns false when there are no more results. If it returns false on the first try, then the steam id is not found.
SirLamer is offline
allenwr
Veteran Member
Join Date: Jan 2006
Location: The place where the karm
Old 02-01-2009 , 19:27   Re: How to find when a line doesn't exist in a SQL DB
Reply With Quote #6

Thank you sir, a return of false would have been easier, I was still looking for an invalid_handle.
__________________
Don't ever place an order with Vee Servers. This is why.
allenwr is offline
Send a message via ICQ to allenwr Send a message via Yahoo to allenwr
SirLamer
Senior Member
Join Date: Oct 2008
Old 02-03-2009 , 19:57   Re: How to find when a line doesn't exist in a SQL DB
Reply With Quote #7

Remember that a query handle, without being processed, basically says "blah blah blah gdgssdgharfhjnfafwsg" to your code. You need to use the SQL functions to bring out results.

If the handle were to equal INVALID_HANDLE then that would mean that the query failed to complete, but that is different than a query returning no results.
SirLamer is offline
Reply



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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 11:25.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode