Jump to content

zero_ZX

Members
  • Posts

    223
  • Joined

  • Last visited

Everything posted by zero_ZX

  1. The plan is to check in the future, not just today :/
  2. It was just a reservation. There are multiples rows with the same car but different dates.
  3. No, the field is not null, and doesn't have a default value.
  4. Yep, but only once, as one specific car only can be rented out once, so no duplicate entries
  5. Hi, So I'm trying to make a car rental project, and I need to show cars of a specific type, available in a specific period. I'm currently using this query: SELECT * FROM car, reservations WHERE car.car_id = reservations.car AND car.type = 1 AND reservations.reserved_from >= "2011-12-22" AND reservations.reserved_to <= "2012-12-20"; So this returns all the cars of the type 1 reserved in 2011-12-22 - 2012-12-20 period. So know that I know which cars are unavailable, how would you go ahead and pick out what's left?
  6. Guess I wasn't clear enough, Ill try to elaborate: As long as the client is running it's updating the tick with one. Let's say I close the application and it stops at 30. Next time the cron job calls the page it sees that it's 30 like last time, then it resets the tick to 0 and do some additional stuff. So the main issue is that I want to do something when the script is not running.
  7. Hi, The main idea is that I have a client running on certain desktops. Each 5th minute the client sends and update to the web-server, increasing "tick" by one. Tick start out as 0, so after 5 minutes ticket should be greater than 5. If tick is not greater than 0 then do <code omitted> I Guess I would need some kind of cronjob to complete this, but i'd love to avoid sessions & cookies at all costs, as the same server is checking the same tick but for different accounts.. Any suggestions are highly appreciated ^.^
  8. Full code: require("./includes/wow.php"); $userid = $user->data['user_id']; /** * This function checks the ban status of the account. * @return 1 if banned */ function checkBan() { $query = "SELECT * FROM wow_logon.accounts WHERE forum_acc = ('$userid')"; $result = mysql_query($query,$connect); if(!$result) die(mysql_error()); $row = mysql_fetch_array($result); if($row["banned"] == "1") { return 1; //$ban_reason = $row["banreason"]; } } Yes, it's inside a function, but what do you mean that i have to pass it?
  9. Hi, So my code returns this: mysql_query() expects parameter 2 to be resource, null given My query & result is: $query = "SELECT * FROM wow_logon.accounts WHERE forum_acc = ('$userid')"; $result = mysql_query($query,$connect); So, something's wrong with my connect variable: $connect = mysql_connect($conf["host"],$conf["user"],$conf["password"]) or die(mysql_error()); mysql_select_db($conf["db"],$connect) or die(mysql_error()); So I don't get why it doesn't work, perhaps the select db isn't parsed, but it's told which database to use in the query :/ Any help is much appreciated.
  10. we are getting somewhere, seems like this was the reason: mysql_close($connect); (which is the very last bit of my code..) thanks a lot
  11. $query = "SELECT * FROM wow_logon.accounts WHERE forum_acc= '".$user->data['user_id']."'"; $result = mysql_query($query,$connect); -> same error, not a bit changed, sorry if I didn't make that clear enough at reply #4 :/
  12. Yea I see, I still wonder why this doesn't work then: $result = mysql_query("SELECT * FROM wow_logon.accounts WHERE forum_acc= '".$user->data['user_id']."', $connect"); It doesn't seem to understand the ,$connect part..
  13. Yep.. but why? :/
  14. Array ( [host] => <ip> [user] => webmin [password] => <pwd> [db] => wow_logon ) [phpBB Debug] PHP Warning: in file /home/fusion/public_html/includes/functions_user.php on line 14: mysql_fetch_array() expects parameter 2 to be long, resource given Array ( [host] => <ip> [user] => webmin [password] => <pwd> [db] => wow_logon ) [phpBB Debug] PHP Warning: in file /home/fusion/public_html/includes/functions_user.php on line 14: mysql_fetch_array() expects parameter 2 to be long, resource given
  15. No, that's why i defined the username, password, host (which is not local) etc in wow.php It just seems to be unable to read it or use it for some reason.
  16. There's no error, it's working perfectly in another file: mysql_close($con); require("./includes/wow.php"); $add_game_acc = ("INSERT INTO accounts(login,encrypted_password,gm,email,flags,lastip,forum_acc) VALUES('$username','$sha1pass',0,'$email',24,'$user_ip','$last_forum_id');"); $debug = mysql_query($add_game_acc); mysql_query($add_game_acc); That's working just fine.
  17. My new code is as recommended: $result = mysql_query("SELECT * FROM wow_logon.accounts WHERE forum_acc= '".$user->data['user_id']."'"); $row = mysql_fetch_array($result, $connect); Error: exactly the same
  18. Thanks for the info Any one else got any idea of why?
  19. Hi, So I'm trying to use another mysql connection to complete a function of mine: /** * This function checks the ban status of the account. * @return 1 if banned */ function checkBan() { require("./includes/wow.php"); $result = mysql_query("SELECT * FROM wow_logon.accounts WHERE forum_acc= '.$user->data['user_id'].', $connect"); $row = mysql_fetch_array($result); if($row["banned"] == "1") { return 1; $ban_reason = $row["banreason"]; } //$user->data['user_id'] mysql_close($connect); } Inside my "wow" file, I have this: <?PHP // Connect to db (edit this vars) $conf["host"] = "**"; $conf["user"] = "**"; $conf["password"] = "**"; $conf["db"] = "**"; $connect = mysql_connect($conf["host"],$conf["user"],$conf["password"]) or die(mysql_error()); mysql_select_db($conf["db"],$connect) or die(mysql_error()); ?> When executing my function I get: [function.mysql-query]: Access denied for user 'nobody'@'localhost' (using password: NO) So, I guess that my function doesn't use the ", $connect" parameter for some reason, any tips?
  20. Hi, So as you might (or might not) have guessed I need to open/close new connections inside my functions. Here's my current code: <?PHP /** * This function checks the ban status of the account. * @return 1 if banned */ function checkBan() { mysql_close($con); require("./includes/wow.php"); $result = mysql_query("SELECT * FROM wow_logon.accounts WHERE forum_acc= '.$user->data['user_id'].'"); $row = mysql_fetch_array($result); if($row["banned"] == "1") { return 1; $ban_reason = $row["banreason"]; } //$user->data['user_id'] mysql_close($connect); require("./includes/config.php"); } ?> When trying to use the function: checkBan(); if(checkban() == "1") { echo'function works, and returns 1. Ban reason: '.$ban_reason.' '; } This gives a pretty good idea of what I try to accomplish I hope, if not, an explanation is below. This code unfortunately returns: [phpBB Debug] PHP Warning: in file /home/fusion/public_html/includes/functions_user.php on line 9: mysql_close() expects parameter 1 to be resource, null given [phpBB Debug] PHP Warning: in file /home/fusion/public_html/includes/functions_user.php on line 12: mysql_fetch_array() expects parameter 1 to be resource, boolean given [phpBB Debug] PHP Warning: in file /home/fusion/public_html/includes/functions_user.php on line 9: mysql_close() expects parameter 1 to be resource, null given [phpBB Debug] PHP Warning: in file /home/fusion/public_html/includes/functions_user.php on line 12: mysql_fetch_array() expects parameter 1 to be resource, boolean given Line 9 & 12: mysql_close($con); $row = mysql_fetch_array($result); Explanation: What I want to do is that I have a user account panel. When the user log in, I want to call a function to check if the user is banned. If the user is banned then we have returned 1, and display some banned message, followed by the ban reason. P.S. is it possible to use stored variables inside a function? When I do this, I connect to another sql server, by first closing the existing connection (if any) and open a new one to execute my statements. Then close that connection and resume the old one.
  21. Hi, I'm trying to code a very basic commenting system, my only worries is how I'm going on about disabling the user from putting any html php etc.. in the comment so it gets displayed on the page.. I have on idea of what to look for, any help is much appreciated I considdered this: strip_tags() but what i want is to display the comment just without actually executing the code if you get me?
  22. Sorry guys, it was a misunderstading in my group We changed the code so it became a bit easier to read: //if (strcmp($extuser,$username) == 0 && strcmp($extpass,$password) == 0) if($extuser == $username && $extpass == sha1($password)) all works flawlessly now.. I still don't get why the other method didn't work though.. To answer your question: I was just trying to check if the usernames and passwords from one databased matched with the info from another. So, all good
  23. Okay, well I changed it.. so my debugging now shows: 139a8cf8be8e[omitted]5f53912224 139a8cf8be8e[omitted]5f53912224-1 Can any one tell me why it returns -1 and not 0 ? :S
  24. I'm only using this on a test basis so i just got the password from here: http://www.ratajik.com/CreateNetPassword/ I created a quick login script to check if username and the password matches with a sql query.. everything goes through just fine.. :/ The quick login script: $password2 = mysql_real_escape_string($_POST['password']); $password = sha1($password2); $username = mysql_real_escape_string($_POST['username']); $q = "SELECT * FROM `profiles` " ."WHERE `username`='$username' " ."AND `password`='$password'" Rest omitted So I find it strange that this other code wont work as expected :/
  25. Hi, So basically this is error: if (strcmp($extuser,$username) == 0 && strcmp($extpass,$password) == 0) extpass is a value it reads from the database. That value is sha1-hashed. Password is plain and is sent via a form. So what happens is the following: extuser and username equals 0, as they match. extpass and password matches IF i put the sha1 hashed password as the password. So no problems in that, it's supposed to work that way. If we change the code a bit, so that the user shouldn't post an unknown password: if (strcmp($extuser,$username) == 0 && strcmp($extpass,sha1($password)) == 0) Right, so we take the submitted password and sha1 it. Then check if that new string matches the database and whops, login failed. Okay.. by doing some debugging by printing the actual values i conclude this: The sha1($password) equals 139a8cf8be8..... while in my database all the letters are CaSe. This is most likely the error.. Any ideas for a fix?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.