Need help with stubborn PHP SQL error

Community Forums/General Help/Need help with stubborn PHP SQL error

Guy Fawkes(Posted 2012) [#1]
Hi all. I need some help with a rather stubborn PHP SQL problem... So what's going on is that mysql_error() is returning Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource... I checked my UPDATE query in my PHP code, time & time again, yet I see NO problem with it. It is STILL returning this error, and I have NO idea what's going on. Can someone PLEASE help me fix it? Here's the link: http://pastebin.com/2Kv2xtzx
Thanks to all who help! :)


degac(Posted 2012) [#2]
Maybe the error is here?
$masterquery = "UPDATE `users` SET `user_id` = \"$genid\" WHERE `username` = \"$user_name\";";

$masterquery = "UPDATE `users` SET `user_id` = '".$genid."' WHERE `username` = '".$user_name."';";



Guy Fawkes(Posted 2012) [#3]
Nope... I'm STILL getting supplied argument is not a valid MySQL result resource :(


Guy Fawkes(Posted 2012) [#4]
Apparently, the mysql_query() is returning 1, instead of a resource array..... :( how do i fix this?


GfK(Posted 2012) [#5]
I'm no PHP/SQL expert, so correct me if I'm wrong, but doesn't MySQL UPDATE return 1 if successful, or 0 if not?

If you intend to be parsing a resource array then you should be using SELECT.


Guy Fawkes(Posted 2012) [#6]
Well. Im just trying to stop ppl from logging in to the same account, either from the same ip, or a different ip, on different browsers.


GfK(Posted 2012) [#7]
What about people who have a dynamic IP address? If you do that and their IP changes, they'll be stuck.


Yasha(Posted 2012) [#8]
You seem to devote a lot of energy to trying to stop users from doing entirely reasonable things. Do you document these unusual behaviours? Because if not, you're going to get a lot of bug reports when things suddenly appear to stop working.

I still remember that time you wanted help deleting the user's files from their machine without permission (which, incidentally, was malware). Is this more of the same logic?


Adam Novagen(Posted 2012) [#9]
deleting the user's files from their machine without permission (which, incidentally, was malware)
Question of curiousity, a bit off-topic but I'll keep it brief: if a program were to include such behaviour in its actual EULA terms agreement - i.e. something like "by installing this program, you acknowledge that any files on your computer may be moved, renamed or deleted without notification" - would it still technically be malware?


Guy Fawkes(Posted 2012) [#10]
Um, no. i do not want anything to do with malware. i JUST wanna prevent people from taking advantage of my membership system by logging in and stealing bandwidth not to mention someone else who WANTS to use it right, and cant, because i had to delete the account due to account fraud..... -.-

Last edited 2012


Guy Fawkes(Posted 2012) [#11]
.

Last edited 2012


Ross C(Posted 2012) [#12]
I don't quite understand...

You don't want people to log into their account, from a different IP address than the one they signed up with? Is this what your wanting to do?


Guy Fawkes(Posted 2012) [#13]
No no no. I just want to prevent membership fraud. How I do that, I really dont care, but I dont want any fraud. I also want to stop OTHER IPs from logging in to an account thats ALREADY logged in.

Last edited 2012


GfK(Posted 2012) [#14]
No no no. I just want to prevent membership fraud. How I do that, I really dont care, but I dont want any fraud. I also want to stop OTHER IPs from logging in to an account thats ALREADY logged in.
With most service providers using dynamic IPs, and so many folks having a range of internet-ready devices and using public wifi hotspots these days, what you're proposing to do is just not practical.


*(Posted 2012) [#15]
what you need to do is check in the game/app whether they are logged in or not and if so dont let em log in again


Guy Fawkes(Posted 2012) [#16]
Ok, thanks Edzup :)


*(Posted 2012) [#17]
the best way is have a timeout variable that increments every second this gets reset every packet they send and if it gets beyond a certain value they get kicked.

As an example my networking system uses 120 seconds as a counter this can be changed in the program, when the player gets beyond the limit the server closes the connection and removes the player. Reasons for the system are in all games you have to have a timeout in case of dropped connections with this in mind its easier to keep track of with that idea than elaborate schemes.

When someone logs back in after dropping they will have to wait for the server to kick the other old connection then allow them in again, there maybe other ways of doing this but this one seems to be in use quite a lot these days :)


xlsior(Posted 2012) [#18]
what you need to do is check in the game/app whether they are logged in or not and if so dont let em log in again


Make sure that they are also -active- though, because it's really annoying if your application (or PC) crashes, or internet connection hiccups and severs the link, and then not being able to re-connect yourself because the server still think that you are already logged in.


Guy Fawkes(Posted 2012) [#19]
How would I check if they are active?


*(Posted 2012) [#20]
Thundros: look at my previous post, best way is to send a ping packet I send 'Ping' in a network message to the clients once every twenty seconds and see how long they take to send 'Pong' back if they dont after the timeout period then they get removed as the connection is dead.


D4NM4N(Posted 2012) [#21]
nvm

Last edited 2012


Guy Fawkes(Posted 2012) [#22]
Ok, but how do i send a ping pong in PHP? Ive done it in blitz, but not in PHP.


Guy Fawkes(Posted 2012) [#23]
?


Guy Fawkes(Posted 2012) [#24]
EDIT: Nvm :)

Last edited 2012