Jump to content

EchoFool

Members
  • Posts

    1,074
  • Joined

  • Last visited

Everything posted by EchoFool

  1. nice one ! Yeahs that pretty much is what im trying to do trying to log down the ID of the effected row so staff can check it out. Thanks
  2. Does any one know if there is such a function to get the ID of the row that was inserted into the database from the query before? Like: //inserted query //get id of the row that was just inserted Been searching cannot find it, but it must surely be a real function some how or must be do-able in some way?
  3. Is it possible to order data in a primary way then a secondary way in the same query? For example some thing like: <?php $Get = mysql_query("SELECT UserID,Title,Infomation,Allowed FROM staff ORDER BY StaffType ASC ORDER BY UserID DESC") Or die(mysql_error()); ?> So you then would have the staff grouped by either admin/coder etc followed by each group sorted by UserID like: Admin: User 2 User 1 Coder: User 6 User 3
  4. Well i tried to avoid them because users can turn them off, thats why was hoping there was a server side method.
  5. Which language is best then ? Flash.. or possibly asp ? =/
  6. Root(folder) - CSS(folder) - page.php - Connect(folder) - include.php Thats my directory tree.
  7. Not really...because i have the directory correct. Anyway, the file that is "Calling" the include is in a folder named "css" So lets say its called page.php so it is here : "/css/page.php" Now page.php needs to include the file : "/connect/include.php" I tried : ../connect/include.php as the "../" brings it back to the root so it can go from there to the folder but no such luck. Hope you can help me out.
  8. I keep getting an error with an include of: This is the include causing the error: <?php include("connect/include.php"); This is the include script: <?php ini_set('error_reporting', E_ALL); $connect = mysql_connect("etc etc etc etc"); //error handle if (!$connect) { echo "Unable to connect to DataBase: " . mysql_error(); exit; } //error handle if (!mysql_select_db("dbtest")) { echo "Unable to select database: " . mysql_error(); exit; } If(strtolower($_SERVER['PHP_SELF']) == '/connect/include.php'){ header("location: ../login.php"); die; } ?>
  9. flash is not php though... I'm asking can it be done in PHP only and nothing else?
  10. I want to create a page where by it is interactive between two people in a live situation. What i mean is , say one user is "waiting" for the other person to make a move. Then that person makes that move and it will auto "refresh" the person who is waiting so that they see that it is their turn? Is there such a way to auto refresh the page of the waiting person ?
  11. which one would you pick personally? Or which one is considered more efficient ?
  12. Won't it add to server resources to put session_start() when you don't use it? Like cos im a bit obsessive with making scripts as efficient as possible ....
  13. I have a global include on my site which checks for which page the user views, and have a pretty large if statement on the go so far which checks quite alot of pages and if the user is on such a certain page then it will do queries and checks for that relevant page. As some pages use the same checks, i used a global include rather just putting it on every script i make. But is putting a huge if statement the best idea? This is generally what I have,,, was wondering if there if there was a more efficient way at all, i am hoping there is not as then i won't have to change it but this is the idea: Try and imagine that there was like another 40 odd more php files to check, i just put 4 for this one to keep the example small to read. <?php If(strtolower($_SERVER['PHP_SELF']) == '/publicforum.php' OR strtolower($_SERVER['PHP_SELF']) == '/login.php' OR strtolower($_SERVER['PHP_SELF']) == '/register.php' OR strtolower($_SERVER['PHP_SELF']) == '/pickyourcity.php'){ If(strtolower($_SERVER['PHP_SELF']) == '/register.php' OR strtolower($_SERVER['PHP_SELF']) == '/pickyourcity.php'){ include("registerinclude.php"); }Else{ session_start(); //code stuff } } ?> Is there a slightly more efficient way than this? Perhaps some kinda case or possibly some kind of function ? I don't know all the possibilities in php there are so many! Hope I am doing the best method! Hope you can share some advice.
  14. Yeh but if the user then presses the button to move up another Y co-ordinate .. the session will still be set and so the query won't happen. Ideally i want the script to only change when the button is pressed and not when the page is refreshed. Thats as simple as i can get with explaining.
  15. I have a problem with my script where by if a user refreshes the page the increment will keep going on a post isset check. Ill explain slightly better now: I have this in my form: <input type="submit" name="Button2" value="Travel"> Now if a user presses it, it runs this script: <?php If(isset($_POST['Button2'])){ $UPDATE = mysql_query("UPDATE tblname SET Y=Y+1 WHERE UserID='{$_SESSION['Current_User']}'") Or die(mysql_error()); } ?> Now if i refresh the page after this just happens, it will still think the Button2 has been set. How ever refresh is needed (without it running the query again) for reasons to do with the games features which i don't need to go into. I tried putting a <?php unset($_POST['Button2']); ?> in the if statement.. But that didn't work.. so hope you have some suggestions you can help me with here.
  16. the user inputs the dates to see logs between certain times... When they pickthe dates in the form it puts it into a format : $Start = //user input format of date("Y-m-d H:i:s",time()); $End = //user input format of date("Y-m-d H:i:s",time()); Then with the 2 variables some how put them into the query.
  17. I have been searching around to find a simple example of how to make a query with a date range... say like: between november 10th 2007 to january 7th 2008 with in the query...but using the date("Y-m-d H:i:s",time()); format to do it. Though i could not find anything for it, not sure if im just putting long winded words into search boxes which comes up with nothing relevant... has any one got a link for me to see one or could you show me a simple example of how it is done? Thankyou
  18. I have a query which gets the days of a date field .. but i need it to do minutes... how is this done? This is my query: $GetHospital = mysql_query("SELECT DATEDIFF(NOW(), `When`) As BeenIn FROM hospital WHERE UserID='{$_SESSION['Current_User']}'") Or die(mysql_error()); When i echo Row['BeenIn']; I get an echo of 1 because its 1 day, even though really it should be in minutes so it would be like 9 minutes or some thing like that... how can i do this?
  19. I have a string i created which works but theres a space that is not carrying into the database... This is what i have: <?php $Log = $Staff.'['.$_SESSION['Current_User'].'] removed '.$RemoveTotal . $ItemName.'from '.$Player.'['.$UserID.']'; The sentence how ever comes out like this: Username[1] removed 2Bags from Username2[2] The part i am trying to correct is the 2Bags to become 2 Bags but I do not know how to add the space..... that part is relating to removed '.$RemoveTotal . $ItemName.'from Hope you can help me.
  20. Why can't we use includes with GET involved like this: include("globalfunctionlist.php?function=1"); because it would be pretty handy to do so..... i just get error syntax relating to it... is there any other way to do this (not using header location how ever) ???
  21. I have a query which doesn't like my curly brackets.... but i don't know how to put it in correctly: $LOG = mysql_query("INSERT INTO stafflog ('UserID','TimeEvent','Log') VALUES ('{$_SESSION['Current_User']}','Date','$Me[{$_SESSION['Current_User']}] has viewed $Choice logs for $Username[$UserID]')") Or die(mysql_error()); where it says: $Me[{$_SESSION['Current_User']}] In the database it would look like Username[234] But i get this error:
  22. I have used an inner join on 2 tables on ItemID but for some unknown reason its getting the wrong row but I don't see how. From the logic i have placed in, it cannot be possible to get the result it is getting, but im sure I've done some silly mistake in the query that i have not spotted so maybe some one here can: <?php $Get = mysql_query("SELECT useritem.ItemID,useritem.Quantity FROM useritem INNER JOIN item ON item.ItemID WHERE item.Trade=1 AND useritem.UserID='{$_SESSION['Current_User']}' AND useritem.Quantity>0") Or die(mysql_error()); ?> I'll show ya the table layout i have with 2 items in ... one is the incorrect one which i will put in red and the other is the one that this query is meant to get. But sadly it grabs the one in red. The reason the red one is incorrect is because Trade is = 0 which is the only difference in my database. So i don't know why it's collecting that itemID of the red row instead of the black... Useritem table: ItemId | Quantity | UserID | ---1--- |-----5-----|----1-----| ---2---|-----1-----|----1-----| Item table ItemID | Trade | ---2---|-----0-----| ---1---|-----1-----|
  23. I don't understand this but i put a js validation in to avoid characters going greater than 1500 characters. So i made 1500 in MS word processor checked the char count then pasted it into my text area. Then i process it and echo the strlen of the textarea in PHP and it comes out at 1542! Every time its always the same....whats going on there? It's not even possible to go above 1500 with the js in place so what exactly could the other 42 chars be ?
  24. Hey, i need help with a table i am using for trade system.. I want to put a "ID" field but i need it to be blank for a while until a certain event, then i need it to insert a unique ID. So it acts as a primary key. But i can't set it as primary key because there could be many rows set to "0" for a while before the field has been updated to a unique ID.... how can i get it to act only as a primary key once a value in a different field equals something? I have a table like this just so you can get what i mean: UserID | RequestID | Wait | RecordID | Now the "UserID" requests to a user on the site .. that user goes in RequestID. Then Wait is a field to tell the user what the situation is. So if Wait is changed to '1' from '0' then the RequestID user has accepted "UserID"s offer. At that point when the user "accepts" the request, that is when i need to insert a RecordID. That recordID is like a unique token to represent the ID of the transaction that they are both going to do but it must be unique every time. This is why i put primary key at first but then realized if i do that they can't all have 0 before hand, because it has to be unique when primary key... Any one got any suggestions on how I should do this without the risk of 2 transactions having the same ID?
×
×
  • 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.