teynon Posted July 26, 2011 Share Posted July 26, 2011 You are evaluating Q as a string. $r = mysql_fetch_assoc("$q"); Try $r = mysql_fetch_assoc($q); Quote Link to comment Share on other sites More sharing options...
WebStyles Posted July 26, 2011 Share Posted July 26, 2011 Again, it seems xc0n was NOT paying attention to the code I gave him. There are no quotes in my examples. Quote Link to comment Share on other sites More sharing options...
teynon Posted July 26, 2011 Share Posted July 26, 2011 @WebStyles: Why pay attention when you can just wait till someone gives you code to copy and paste? Edit: ^^ Was suppose to be sarcasm... But... Actually, you did post the code to copy and paste. @xc0n: Let this be a lesson. If you don't pay attention, even copy and paste doesn't work. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted July 26, 2011 Share Posted July 26, 2011 xc0n, are you a sociology class conducting an experiment? I can think of no other reason why you are taking code and information given in the responses and altering it so that it does not match the database table you have and even changing where you are putting the statements in the program, from what you had earlier in the thread, so that the code cannot work without errors. Quote Link to comment Share on other sites More sharing options...
WebStyles Posted July 26, 2011 Share Posted July 26, 2011 @teynon: there are some days when things just get to me, normally I'm a much more patient guy, but sometimes, having to say the same thing 3 times just makes me question why I even bother trying to help. At the end of the day though, many people are grateful and I feel good being able to help a few, but sometimes it's just hard. I do tend to just post some copy/paste(able) code as many times it's just faster and easier than trying to explain every little detail and from what I've seen around here, around 70% of people posting questions don't really seem interested in how or why it works, they just want a quick fix. It's the other 30% that makes everything worth it. cheers to you and PFMaBiSmAd for understanding my little outbreak (for which I apologize) Quote Link to comment Share on other sites More sharing options...
xc0n Posted July 26, 2011 Author Share Posted July 26, 2011 well u were all f#@kin wrong in the end i fixed it my self the errors in code i pasted was me editing to try new things, eg adding the "" quotes and trying new database details, ur all wingers... relax up a bit this is a help forum and what helped in the end was figuring it out myself! You all need to buy some tampons for your big vagina's. Quote Link to comment Share on other sites More sharing options...
WebStyles Posted July 26, 2011 Share Posted July 26, 2011 Ah the joy of helping strangers. Glad our efforts and time are appreciated in such an intense manner. Hope to see you again soon xc0n. Quote Link to comment Share on other sites More sharing options...
Philip Posted July 26, 2011 Share Posted July 26, 2011 It's amazing what happens when you try things yourself, isn't it xc0n? In any case, please refrain from biting the hands that are trying to feed you. Quote Link to comment Share on other sites More sharing options...
teynon Posted July 26, 2011 Share Posted July 26, 2011 Go figure. It wasn't the quotes, according to him, but he doesn't want to post what he did to fix it. Way to help future readers out. But then again, its obvious you don't like people who help people. Quote Link to comment Share on other sites More sharing options...
premiso Posted July 26, 2011 Share Posted July 26, 2011 Order of Operations. <?php $user_ip = $_SERVER['REMOTE_ADDR']; $conn = mysql_connect("localhost", "user", "pass")or trigger_error("cannot connect to mysql server: " . mysql_error()); // your database connection function mysql_select_db("database") or trigger_error("cannot select DB: " . mysql_error()); $q = mysql_query("select `id` from `allowed_ips` where `validate_ip` = '$user_ip' limit 1") or trigger_error('IP Query Failed: ' . mysql_error()); if (is_resource($q) { $r = mysql_fetch_assoc($q); } The first thing was that your mysql_query was before the select_database, so it was not able to query properly and probably threw a "database not selected" error. A few key notes, handle data properly. By checking if $q is a resource, you know your script will not cause havoc in case something failed and throw errors. And you can handle the error to display a nice message to the user. mysql_close is not needed to be called (unless maybe you want to connect to multiple mysql servers). PHP is smart enough to close the connection upon the script ending. Using or trigger_error is preferable over DIE as you can then handle the error nicely, it does not kill the script and for production, you can disable the display of errors to hide the important information from the average viewer. So give that code a try and see what error gets spat out at you. Quote Link to comment Share on other sites More sharing options...
xc0n Posted July 27, 2011 Author Share Posted July 27, 2011 thanks premiso for actially posting help instead of payign out on me like the others!, i got angry cause use were basically calling me an idiot, thsi is a help forum... @teynon: u think takeing out the quotes fixed it?? wrong buddy ill post MY code below to prive u wrong your two cents wasnt needed... @PFMaBiSmAd: you are a stain on earth! @KingPhilip: they wernt helping they were giving me shit cause im new to php this is a help forum not a dam opinion forum... so i dont need your crappy reply either. @everyone else: thanks for the help from he people who actually tried to help me and not be stuck up idiots. I had two people telling me how to fix the problem hence the errors in the code i was posting... ahhhhhh get a life. i just wanted help and the douchbags started winging about me, hence me telling them to go buy some tampons, is that really that bad? i thought the tampons would help with there pms. Quote Link to comment Share on other sites More sharing options...
xc0n Posted July 27, 2011 Author Share Posted July 27, 2011 @teynon: here is MY code u knob <?php $dbhost = 'localhost'; $dbuser = 'blah'; $dbpass = 'blah'; $dbname = 'blah'; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error Connecting to MYSQL'); mysql_select_db($dbname); $user_ip = md5($_SERVER['REMOTE_ADDR']); $q = mysql_query("select `id` from `allowed_ips` where `ips` = '$user_ip' limit 1"); $r = mysql_fetch_assoc($q); @mysql_close($conn); if(!empty($r)){ ?> u happy now??? see i did fix it your wrong go press up as a army guy and shoot bb guns Quote Link to comment Share on other sites More sharing options...
WebStyles Posted July 27, 2011 Share Posted July 27, 2011 Brilliant. That code is basically what I posted for you on the first page of this topic, except you still have something wrong in it. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted July 27, 2011 Share Posted July 27, 2011 So, is this thread solved or not? There's a "Topic Solved" button at the lower left-hand side of the page, in case you missed it? Quote Link to comment Share on other sites More sharing options...
premiso Posted July 28, 2011 Share Posted July 28, 2011 thanks premiso for actially posting help instead of payign out on me like the others!, i got angry cause use were basically calling me an idiot, thsi is a help forum... If I would have known you behaved like an asshat, I wouldn't have bothered. There is no need to put down people trying to help you out. If they troll you, take it off your chin like a man and not be an asshole about it. Quote Link to comment Share on other sites More sharing options...
Maq Posted July 28, 2011 Share Posted July 28, 2011 xc0n, I understand your frustration but don't exacerbate onto others (sounds dirty). This is a free service with volunteers and the the people you put down have been here for years and some are the most helpful members of this board. I wouldn't be surprised if they ignore your future questions, don't bite the hand that feeds you... @Everyone, now let's play nice and get along Quote Link to comment Share on other sites More sharing options...
.josh Posted July 28, 2011 Share Posted July 28, 2011 Near as I can tell, teynon "started it" here: @WebStyles: Why pay attention when you can just wait till someone gives you code to copy and paste? Edit: ^^ Was suppose to be sarcasm... But... Actually, you did post the code to copy and paste. @xc0n: Let this be a lesson. If you don't pay attention, even copy and paste doesn't work. IMO even the edit doesn't "help" or "justify" the first statement. And then PFM followed up with... xc0n, are you a sociology class conducting an experiment? xc0n clearly has problems listening or paying attention to what's being told. Maybe it's because he is an idiot, or maybe he's just another 13 year old with the attention span of a ferret on crack...who knows, but regardless, you guys bit out of frustration, and he bit back, in response. @xc0n: I'm not going to necessarily fault you for biting back, when others "started it". But people get really frustrated when someone comes asking for help and doesn't make an effort to listen to the help they asked for. If you are going to ask questions on a help forum, you need to make an effort on your end to pay attention to what is being told. If you don't understand, ask for clarification. And if you do not pay attention or try what is given, expect people to be frustrated about it and respond accordingly, and even bite you for it. And while you're certainly welcome to bite back...that obviously doesn't solve your problem. My best advice to you would be to recognize and admit (at least to yourself) that you aren't making the necessary effort, take your lashings like a man, and make it a lesson learned. Programming takes effort. For whatever you think you've just accomplished with this bit of code, it is still poorly written and vulnerable and begging for problems down the road. And when you ask for help later on it...do you really think people are going to help you, after all this? Yes, this is a "help" forum, but we arenot here to spoon feed people or do their work for them or wait on them hand and foot or walk on thin ice or any of that shit. We are here to help people with their problems when they are trying to make an effort to solve them, and to help them learn something. Have you seen any kung-fu flicks? You know like where it shows lots of monks in a monastery trying to learn kung-fu and they have the master there and when they aren't paying attention or something...WHACK. If you are serious about learning something. That is the difference between being "punished for doing something wrong" and being "disciplined so that you learn to stop doing wrong." @others: I understand being frustrated when someone isn't listening, and I understand calling them out on it, and I'll even to an extent turn a blind eye to a sharp tongue. But don't dish it out unless you yourself are prepared to be served. If they want to respond by biting back then they probably aren't all that serious about their issue or trying to learn to begin with. But don't go crying foul when someone bites you when you bit them first. Even if it is out of frustration, you're still biting. Quote Link to comment Share on other sites More sharing options...
xyph Posted July 28, 2011 Share Posted July 28, 2011 You only said bit or a variation 11 times. I'm not impressed. Quote Link to comment Share on other sites More sharing options...
xc0n Posted July 29, 2011 Author Share Posted July 29, 2011 @admin i agree with you... maby i went a bit overboard, in the end i guess i got the code mixed up a bit due to multiple people trying to help me, and also in the end i got my script working thanks to you guys so yea i cant complain! This has been my favorite first topic in a forum ever!! lol Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.