Jump to content

EchoFool

Members
  • Posts

    1,074
  • Joined

  • Last visited

Everything posted by EchoFool

  1. Well "getusername" checks if userid exists in usertable and checks if they are staff (as staff are different coloured username) and also gets the username. unless i could some how check across all 3 tables in one query but i always thought calling a function was the efficient method as i can call it all over the site without duplicated lines of code =/
  2. Im assuming your suggesting here - i do an inner join on contactid on social table and user id in the user table to get username ?
  3. Well the list friends thing is used on many subdomains so a function was a must. Should i just make it echo from the function instead then =/ ?
  4. Ok tried this: But i get unlimited / endless while looping <?php function listfriends($UserID){ $SELECT = mysql_query("SELECT ContactID FROM social WHERE UserID='$UserID' AND Type='Friend'") Or die(mysql_error()); $row = mysql_fetch_assoc($SELECT); return ($row); } while($row = listfriends($_SESSION['Current_User'])){ getusername($row['ContactID']).'<a href="#">[Mail]</a> <a href="#">[Remove]</a><br>'; } ?>
  5. Hey, I have a function which returns a query result like this : <?php return(mysql_fetch_assoc($Query); ?> Then my script has: <?php While($row = functioname()) { // do stuff } ?> But for some reason this method does not work... does any one know how i can do the idea im trying to do cos currently it just loops for infinity..
  6. Thank you everything seems to be in working order !
  7. Okay that worked but the WHERE clause is missing yet for some reason with this: <? SELECT TIMESTAMPDIFF(MINUTE, `arrival` , NOW() ) as MinutesPassed, Minutes - TIMESTAMPDIFF(MINUTE, `arrival` , NOW() ) as MinutesLeft FROM hospital WHERE MinutesLeft > 0 ORDER BY MinutesLeft ASC ?> I get : Unknown column 'MinutesLeft' in 'where clause' Makes no sense as without it - the ORDER BY doesn't give an unknown column error :S So it must be setting but not useable in a WHERE ?
  8. No just how long is left for them to wait - don't want to over complicate it
  9. Okay thats better! Although the ORDERBY is last part not working. As people can be in different lengths of waiting times other than just the same wait.. Person 1 has 2 minutes have passed and was a 20 minute wait = 18 mins to go. Person 2 has 2 minutes have and was a 10 minute wait = 8 mins to go. So person 2 would be before person 1 in terms of the order by. Im thinking a subtraction but can maths be used in an orderby?
  10. With the first query - where is "MinutesWaited" coming from as that would be undefined ? The second query resulted in this: <?php echo $row['MinutesPassed'] .' passed '. $row['MinutesLeft'].' left '; ?> 0 passed -10 left
  11. edit: hmm it seems to be stuck on 0 now matter how many minutes have passed =/
  12. Arrival is TimeStamp YYYY-MM-DD HH:mm:ss 2010-03-27 02:14:10 It resulted in : 0 minutes! Which would be correct as 0 minutes had passed from when i inserted the row. But now lets say field : Minutes is 10... that means they have to 10 till the result > or = to Minutes which is where my WHERE Clause comes in, i want to check where "how long they've been waiting from row insert" taken from "mintes - how long they have to wait" and find only where its > 0 minutes left. Then order by minutes left ASC order but it finds nothing with my WHERE and ORDER part.
  13. Hmm its first time ive had a white screen as opposed to a error being displayed in over a year. I'l have to investigate.
  14. so does my server log the cause of a white page in my logs file .txt or i just got to try to find the mistake ?
  15. Hey, I have this on my page: error_reporting(E_ALL|E_STRICT); ini_set("display_errors", 1); But for some reason i still get white pages when i get errors... have i got the right errors set or does it not include all error types?
  16. Hey, I have a query which lists users in hospital and how much time they have left to wait based on "now" and "Arrival" time stamps.... but it works until i a WHERE and ORDER BY clause. Im trying to only display people who have 1 minute left or greater in the WHERE CLAUSE And ORDER BY minutes left in an ASC order but when i add them my query fails to find anything... this is my query: <?php SELECT UserID,Reason,TIMESTAMPDIFF(MINUTE,'Arrival','".serverdate()."')AS MinutesPassed,Minutes FROM ".tablename().".hospital WHERE (TIMESTAMPDIFF(MINUTE,'Arrival','".serverdate()."')- Minutes) > 0 ORDER BY (TIMESTAMPDIFF(MINUTE,'Arrival','".serverdate()."')- Minutes) ASC ?> Hope you can help with my problem... Time stamps and serverdate function are informat of: yyyy-mm-dd hh:mm:ss
  17. Similiar to mysql_insert_id is there a way to get the ID of the row that updated from the previous query?
  18. Im not really a MYSQL expert so i don't know what you mean by proper constraints? What about if i want to optimize all tables in all my databases?
  19. Hey, Quick question - is there a way to build a query so that it will delete all rows of data from any database / tablename from my server that has the field "UserID" and "UserID = 0" ? Or do i have to be more precise in my MYSQL to do it which im hopeing not.
  20. Because my alternative is to go through thousands of lines of codes and hundreads of scripts and replace mysql_error to my own custom function and that is going to take weeks.
  21. Hey, If i make a function named "function mysql_error()" Will php allow me ? Because mysql_error is already set up as default will it not allow me to use it or will it use my function over the pre-default one ? OR can i just find a way to edit mysql_error() as that would save me editing alot of scripts.
  22. Is there much point in using any thing other than rand if its just choosing between 15 rows?
  23. Hi, Was just enquiring if orderby rand() was efficient and "truely" random. As PHP has rand() and a faster mt_rand which is why i ask if MYSQL has any faster rand version? Also is MYSQL the best use for less server load for random row selection compared to putting rows in arrays and then randomly select the row from the array?
  24. Hey i have a file_exists function that checks full urls to file locations but it does not work... my function is as below: <?php function imagecheck($Path){ If(file_exists($Path)){ return ($Path); }Else{ return ('http://www.mydomain.com/images/default.png'); } } ?> The url to the image is correct as i put the full url in my browser and it found the image but file_exists does not :S In this situation my variable is can any one figure out why it won't work yet the file does exist as currently it returns the "default" image :S
×
×
  • 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.