Jump to content

thedevilinu

Members
  • Posts

    16
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

thedevilinu's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. This problem is for real PHP freaks. I do not post in forums unless I really can't find a solution. I have been bugged by this for days now. Here it is. I have a page signup.php among other pages on the website. Once you logout from logout.php all session is destroyed and all cookies are deleted. you can visit the website as a visitor after logging out. I visited all pages to make sure I was really logged out. Everything is normal up till here. However, when I click on signup again which call signup.php, the old session becomes suddenly alive and you are logged in again as if you had never logged out. I have never faced this problem before and I have made many websites using PHP. I have tested and found that session is already there when the page loads and values are not formed by any variable or function manipulation. I am using hostgator shared hosting. Please guyz help me out. I am not sure what I am doing wrong here.
  2. Thankyou!! Thankyou!! Thankyou!! I don't have any money with me now else would have definitely made a donation. You are really good. Thanks again.
  3. Thanks for the valuable suggestion and all the time you spent on the problem. Can you please tell me if fulltext sesarch work on phpmyadmin as well as it said it works on Isam only.
  4. Ahh. Sorry for not making it clear at the very first place.. I am not counting the number of times a particular user appears in the four queries. What I wanted to do was to arrange users by the keywords they have in their profile and number of times these keywords appear in their profile so for a query like this.. SELECT *, 1 as grouporder FROM table WHERE city='Jaipur' and subjects LIKE '%social science%' UNION SELECT *, 2 as grouporder FROM table WHERE city='Jaipur' and (subjects LIKE '%social%' or qualifications LIKE '%social%' ) UNION SELECT *, 3 as grouporder FROM talbe WHERE city='Jaipur' and (subjects LIKE '%Science%' or qualifications LIKE '%Sceince%' ) ORDER BY grouporder, id DESC if someone is looking for a tutor which teaches "social science".. I will first of all find tutors which have keyword "social science" and then find tutors which have either "social " or "science" in their profile.. and whoever has these keywords repeated highest number of times.. gets prominance.. Please let me know if I have made myself clear enough before writing another code.
  5. problem here .. two things are happening.. first of all, it's not ordering them in the order of increasing order but rather than that, it's ordering them in the asc id .. and secondly.. now none of the other content but id is displayed. However, the rows aren't repeating now so that's a good part. wht's the significance of allusers in the code?
  6. So now my query looks like this... SELECT id, COUNT(*) AS countof FROM table WHERE city='delhi' and subjects LIKE '%math%' UNION SELECT id, COUNT(*) AS countof FROM table WHERE state='Delhi' and subjects LIKE '%math%' UNION SELECT id, COUNT(*) AS countof FROM table WHERE city='delhi' and (subjects LIKE '%math%' or qualifications LIKE '%math%' ) UNION SELECT id, COUNT(*) AS countof FROM table WHERE state='Delhi' and (subjects LIKE '%math%' or qualifications LIKE '%math%' ) Group by id ORDER BY countof DESC and gives the following error.. Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause
  7. The only problem I am facing with the group by method is that it repeats the same tutors again and again when used with UNION. Is there any way to counter this. I really appreciate the help
  8. I just faced a problem with the last suggestion. What's happening now is that the same results are being repeated whereas unique results came earlier. Please advise when i wasnt doing the grouporder thing
  9. Wow.. nice code.. it is small and works just the way I wanted it to. I did manage to do the same thing by making an array of queries.. it was way too much php.. I am also trying to now sort the tutors by the number of times the keywords repeat in a profile.. it would be just a modification of the last code.. so if a user inputs subject as 'social science', the code should sort people (ids) by the number of times 1. 'Social science' repeats in various fields (subjects, qualifications, experience) 2. 'social' repeats in various fields (subjects, qualifications, experience) 3. 'science' repeats in various fields (subjects, qualifications, experience) whichever has the highest count will get the top priority.
  10. Here is a code which will select the people in decreasing order of relevance. SELECT * FROM table WHERE city='Jaipur' and subjects LIKE '%All Subjects%' UNION SELECT * FROM table WHERE city='Jaipur' and (subjects LIKE '%All%' or qualifications LIKE '%All%' ) UNION SELECT * FROM talbe WHERE city='Jaipur' and (subjects LIKE '%Subjects%' or qualifications LIKE '%Subjects%' ) and this works good. The problem starts when I try to sort them by ID. So when I try to do this.. SELECT * FROM table WHERE city='Jaipur' and subjects LIKE '%All Subjects%' UNION SELECT * FROM table WHERE city='Jaipur' and (subjects LIKE '%All%' or qualifications LIKE '%All%' ) UNION SELECT * FROM talbe WHERE city='Jaipur' and (subjects LIKE '%Subjects%' or qualifications LIKE '%Subjects%' ) ORDER BY id DESC ............this works fine as well but it messes up the order.. all the elemtns from 3 queries get mixed up. what I want is something like this.. but this doesn't work..I hope what I want is fairly clear from the query but it's not working in practice. Please help. SELECT * FROM table WHERE city='Jaipur' and subjects LIKE '%All Subjects%' ORDER BY id DESC UNION SELECT * FROM table WHERE city='Jaipur' and (subjects LIKE '%All%' or qualifications LIKE '%All%' ) ORDER BY id DESC UNION SELECT * FROM talbe WHERE city='Jaipur' and (subjects LIKE '%Subjects%' or qualifications LIKE '%Subjects%' ) ORDER BY id DESC
  11. @PFMaBiSmAd - I really expect the loop to run just once as their is only a single id associated with any email. You are however right in saying that loop is running more than once. I can't fathom why it is running twice. so changing the code to ------------------------------ $result = mysql_query("SELECT * FROM indiatutors_profiles WHERE id='$id' ") or die(mysql_error()); while($row=mysql_fetch_array($result)){ echo $email =$row; } ------------------ gives me error ---------------- email@gmail.com Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in website_path/profiles.php on line 7 ---------- which confirms that loop runs twice. Bug was using another $result statement in the code due to which it was running again. Thanks for sorting this out for me. Thanks again @rifts - it works either way mate..my way is just time saving @dragon - echo in or out of the loop .. either way it shouldn't give an error
  12. I am trying to run the following code -------------------------- $result = mysql_query("SELECT * FROM indiatutors_profiles WHERE id='$id' ") or die(mysql_error()); while($row=mysql_fetch_array($result)){ $email =$row; } echo $email; ---------------------------- It gives me the following error Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in website_path/profiles.php on line 7 The funny thing about the code is that inspite of giving the error, it outputs the email correctly based upon the id which it shouldn't have done if their was some error
  13. Ah!! You are right about that explode and array thing.. however here's a brilliant function i picked up which does exactly what I wanted to function multiexplode($delimiters,$string) { $return_array = Array($string); // The array to return $d_count = 0; while (isset($delimiters[$d_count])) // Loop to loop through all delimiters { $new_return_array = Array(); foreach($return_array as $el_to_split) // Explode all returned elements by the next delimiter { $put_in_new_return_array = explode($delimiters[$d_count],$el_to_split); foreach($put_in_new_return_array as $substr) // Put all the exploded elements in array to return { $new_return_array[] = $substr; } } $return_array = $new_return_array; // Replace the previous return array by the next version $d_count++; } return $return_array; // Return the exploded elements }
  14. Can you please explain "explode() does not take an array as the first argument"? This is the text that I found in php.net on explode function "Returns an array of strings created by splitting the string parameter on boundaries formed by the delimiter. " There is also an example pizza = "piece1 piece2 piece3 piece4 piece5 piece6"; $pieces = explode(" ", $pizza); echo $pieces[0]; // piece1 echo $pieces[1]; // piece2 The only difference in his pizza and mine is that it's pieces are seperated by a space and mine were seperated by a newline. Moreover, the funny thing is that echo $value works exacly same for $badarray in both cases. This is the first time I have faced a problem with explode. I use it very often to split things in to array including passing variables in the url for SEO purposes
  15. No error came when I put that. However, I noticed something funny. When $bad is insterted from textarea seperated by a newline in the form of 1@a.com 2@b.com .................. and then $badarray is formed by the above code, it doesn't work. It will only work if I have one value there. However if I manually define $badarray as $badarray=array('1@a.com','2@b.com'.......) IT WORKS Output of echo $view, however, remains same in both case
×
×
  • 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.