Jump to content

Barand

Moderators
  • Posts

    24,563
  • Joined

  • Last visited

  • Days Won

    822

Everything posted by Barand

  1. try $sql = "SELECT u.userid, u.username FROM users u JOIN friends f ON u.userid = f.user1 WHERE f.user2 = $loggedinuser AND u.username LIKE '%$term%' UNION SELECT u.userid, u.username FROM users u JOIN friends f ON u.userid = f.user2 WHERE f.user1 = $loggedinuser AND u.username LIKE '%$term%' ORDER BY username";
  2. There's a section in the PHP Manual on multiple file uploads http://php.net/manual/en/features.file-upload.multiple.php
  3. I thought I had but I'll try again. This time I'll use the revised alias name as that it probably what was causing the confusion. Having a field called "has_email" that is true when there is NO email is illogical to me. SELECT email IS NULL or email = '' empty_email FROM formdata WHERE promoCode = '$varPromo' "empty_email" is true if there is no email. Just by changing the alias from "has_email" to "empty_email" the PHP if statement becomes more readable and makes logical sense if (!$row['empty_email']) { // if the email is not empty
  4. if ($row['has_email']) { This will be true when there is NO email (ie if it is null or blank) so your test needs to be if (!$row['has_email']) { to see if there is an email address edit : perhaps a better alias would be "empty_email"
  5. You were told the answer in #6 above. Regardless of what password the user posted, you always encrypt the word 'hash'. Also the method of encrypting when you store it in the database is not the same as the one you are using now to test if they are the same. This is when you store it $hash='hash'; $password = hash('sha256', $salt . $hash); This when you check it $hash=hash('sha256', $userdata['salt'] . hash('sha256',$password)); Read the replies! Otherwise you are just wasting our time.
  6. Before I attempt the query a few comments on the data That is not the same data as before. Point values have changed and extra rows. It is now a prime example of why you cannot rely on id for the sequence. ID 7 has an earlier date than ID 6. That means you need sortable date formats and you are still using the original (useless) format. You have multiple visits on the same date - which is the "last" on 14/12, the one with 5 points or the one with 6? You need DATETIME fields if multiple daily visits are allowed.. Once the data issues are resolved then we can start with the query.
  7. I used "appointment" instead of "appointments" so change the subquery to SELECT DISTINCT a.app_id as pair_id, b.app_id FROM appointments AS a CROSS JOIN appointments as b As for what it does Running on the data you posted gave this mysql> SELECT DISTINCT allrecs.pair_id -> FROM -> ( -> SELECT DISTINCT a.app_id as pair_id, b.app_id -> FROM appointment AS a -> CROSS JOIN appointment as b -> ) allrecs -> LEFT JOIN -> google_calendar gc USING (pair_id, app_id) -> WHERE gc.pair_id IS NULL -> ORDER BY pair_id; +---------+ | pair_id | +---------+ | 2 | | 3 | +---------+
  8. Then you need to check that all your {}s are in balanced pairs.
  9. You can use STR_TO_DATE() to convert that useless format of yours into the correct yyyy-mm-dd format ... WHERE STR_TO_DATE(mydate, '%a %b %d %Y') BETWEEN d1 AND d2 d1 and d2 should be in yyyy-mm-dd format EG mysql> SELECT STR_TO_DATE('Fri Jan 05 2014', '%a %b %d %Y') as date; +------------+ | date | +------------+ | 2014-01-05 | +------------+
  10. h1234, Why don't read the replies in your other thread/s on this problem (http://forums.phpfreaks.com/topic/283047-password-does-not-work-it-always-recognises-it-as-inccorrect-even-tho-its-correct/?do=findComment&comment=1454283) and stop wasting our time by posting the same problem in different threads.
  11. Do a search on your code for "<?". If it isn't followed by "php " then change it to "<?php "
  12. yes. In the case I quoted^^, you have string - string - string - integer parameters
  13. your bind statements are wrong $stmt->bind_param("ssi", $firstname, $addressname, $phone, $id); // should be "sssi"; and your other is also missing "s"
  14. and you expect hash('sha256', $userdata['salt'] . hash('sha256',$password)) to be equal to hash('sha256', $salt . 'hash'); The password you encrypt and store is always 'hash'
  15. Have you tried leaving money under your pillow to see if the Code Fairy leaves some? If that fails, try freelance section of the forum.
  16. You output the success message in all cases if (mysql_num_rows($query) > 0) { echo "Username and password already exist!"; } else { // execute the insert query mysql_query ("INSERT INTO `medionline`.`employees`(name,surname,id_number,contact_number,job_id,username, password) VALUES ('$name','$surname','$id_number','$contact_number','$job_id','$username','$password')"); // query for insert data } echo ("User registration Successfull"); $connection->closeConnection(); // closing the connection Easier to see when you use indentation
  17. $hash=hash('sha256', $userdata['salt'] . hash('sha256',$password)); Is that exactly the same method that you use when you originally encrypt the user's password for storing in the table?
  18. Find all combinations then left join to see which are absent SELECT DISTINCT allrecs.pair_id FROM ( SELECT DISTINCT a.app_id as pair_id, b.app_id FROM appointment AS a CROSS JOIN appointment as b ) allrecs LEFT JOIN google_calendar gc USING (pair_id, app_id) WHERE gc.pair_id IS NULL ORDER BY pair_id;
  19. Have you looked at MySQL's "LOAD DATA INFILE" statement http://dev.mysql.com/doc/refman/5.6/en/load-data.html
  20. If you read the FAQ for this forum first you would know that you get that error when the query fails. In this case you have a syntax error. You need a WHERE clause. Try $query = "SELECT `firstname` FROM `users` WHERE `firstname` LIKE '".mysql_real_escape_string($search_text)."%'"; Next time you post code, use the forum's [ code ]..[ /code ] tags or use the <> button in the toolbar
  21. How many more topics do you intend to create with this problem?
  22. If you get that error, your query failed (see FAQ) Check the value of mysql_error() after running the query
  23. Are you sure it's an issue? $str = <<<XML <A> <Category name='Toys > Other'> <Item>item 1</Item> <Item>item 2</Item> <Item>item 3</Item> </Category> <Category name='Games > Other'> <Item>item 4</Item> <Item>item 5</Item> <Item>item 6</Item> </Category> </A> XML; $xml = simplexml_load_string($str); foreach ($xml->Category as $cat) { echo "{$cat['name']}<br>"; foreach ($cat->Item as $i) { echo " • $i<br>"; } } /********** OUTPUT ********** Toys > Other • item 1 • item 2 • item 3 Games > Other • item 4 • item 5 • item 6 *******************************/
  24. Read my reply #12 to restrict to the current month (or selected month) 3 and 4 refer to the time the center started, prior to which there would be zero students. Therefore the number lost since then must be 0 and the number gained since then must be all current students.
×
×
  • 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.