-
Posts
24,563 -
Joined
-
Last visited
-
Days Won
822
Everything posted by Barand
-
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";
-
PHP Newbie Upload Link Scripting/Folder Question
Barand replied to graphxsman's topic in PHP Coding Help
There's a section in the PHP Manual on multiple file uploads http://php.net/manual/en/features.file-upload.multiple.php -
PHP If Else Not working like i thought it would
Barand replied to Travist6983's topic in PHP Coding Help
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 -
PHP If Else Not working like i thought it would
Barand replied to Travist6983's topic in PHP Coding Help
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" -
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.
-
selecting/searching rows of a Table based on the value of a field in the table.
Barand replied to ajoo's topic in MySQL Help
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.- 22 replies
-
- ajoo
- conditional search query
-
(and 1 more)
Tagged with:
-
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 | +---------+
-
Then you need to check that all your {}s are in balanced pairs.
-
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 | +------------+
-
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.
-
Do a search on your code for "<?". If it isn't followed by "php " then change it to "<?php "
-
yes. In the case I quoted^^, you have string - string - string - integer parameters
-
your bind statements are wrong $stmt->bind_param("ssi", $firstname, $addressname, $phone, $id); // should be "sssi"; and your other is also missing "s"
-
Random generation number on submit button and send a mail to the user
Barand replied to Revs's topic in PHP Coding Help
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.- 2 replies
-
- php
- javascript
-
(and 1 more)
Tagged with:
-
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
-
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;
-
Have you looked at MySQL's "LOAD DATA INFILE" statement http://dev.mysql.com/doc/refman/5.6/en/load-data.html
-
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
-
How many more topics do you intend to create with this problem?
-
If you get that error, your query failed (see FAQ) Check the value of mysql_error() after running the query
-
Html entities inside attribute values of an xml?
Barand replied to kutchbhi's topic in PHP Coding Help
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 *******************************/ -
Filtering data on the dataset using the same dataset for subquery filtering
Barand replied to mbaric's topic in MySQL Help
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.