[email protected] Posted April 24, 2006 Share Posted April 24, 2006 Hi guyzI am in need of help with my php/mysql. It has given me headaches. It works fine in mysql but not in php. basically i want to filter result for the user who is currently logged in. Can someone plzzzzzzz have a look and tell me where im going wrong. Thanks in advanceI have a following select statement $sql = "select users.rep_name, rep_table.rep_name, rep_table.rep_id, customer_table.* " . "from customer_table, rep_table, users ". " where users.rep_name=rep_table.rep_name and customer_table.rep_id=rep_table.rep_id and account_no like '".$_GET['keywords']."'";when i enter account_no it should only filter information associated with that particular "rep_name" if matched other wise it should return nothing but it still return results.in mysql it works:mysql> select users.rep_name, rep_table.rep_name, rep_table.rep_id, customer_table.* from customer_table, rep_table, users where users.rep_name=rep_table.rep_name and customer_table.rep_id=rep_table.rep_id and account_no=1564;+---------------+---------------+--------+------------+--------------------------+-----------------+----------+-----------------+----------+-----------+--------------+------------+--------+--------------+| rep_name | rep_name | rep_id | ACCOUNT_NO | CUSTOMER_NAME | ADDRESS1 | ADDRESS2 | ADDRESS3 | ADDRESS4 | POST_CODE | TELEPHONE_NO | RUN_NUMBER | REP_ID | CONTACT_NAME |+---------------+---------------+--------+------------+--------------------------+-----------------+----------+-----------------+----------+-----------+--------------+------------+--------+--------------+| Alan Fishwick | Alan Fishwick | 3 | 1564 | Southend Bathroom Centre | 187 London Road | NULL | Southend-On-Sea | Essex | SS1 1PW | 01702 433445 | 9 | 3 | Mark Daniels |+---------------+---------------+--------+------------+--------------------------+-----------------+----------+-----------------+----------+-----------+--------------+------------+--------+--------------+1 row in set (0.00 sec)ORmysql> select users.rep_name, rep_table.rep_name, rep_table.rep_id, customer_table.* from customer_table, rep_table, users where users.rep_name=rep_table.rep_name and customer_table.rep_id=rep_table.rep_id and account_no=109819;Empty set (0.00 sec) Quote Link to comment https://forums.phpfreaks.com/topic/8241-problem-with-phpmysql-select-statement/ Share on other sites More sharing options...
wisewood Posted April 24, 2006 Share Posted April 24, 2006 I hope that person is fictional, otherwise he just had his personal details splattered all over the internet.Try this:[code]$query = "SELECT users.rep_name, rep_table.rep_name, rep_table.rep_id, customer_table.* FROM customer_table, rep_table, users WHERE users.rep_name = rep_table.rep_name AND customer_table.rep_id = rep_table.rep_id AND account_no LIKE '$_GET[keywords]'";[/code] Quote Link to comment https://forums.phpfreaks.com/topic/8241-problem-with-phpmysql-select-statement/#findComment-30046 Share on other sites More sharing options...
[email protected] Posted April 24, 2006 Author Share Posted April 24, 2006 nope it made no difference :( Quote Link to comment https://forums.phpfreaks.com/topic/8241-problem-with-phpmysql-select-statement/#findComment-30051 Share on other sites More sharing options...
wisewood Posted April 24, 2006 Share Posted April 24, 2006 $query = "select users.rep_name, rep_table.rep_name, rep_table.rep_id, customer_table.* from customer_table, rep_table, users where users.rep_name=rep_table.rep_name and customer_table.rep_id=rep_table.rep_id and account_no=1564";cant see any reason for it not to work.have you tried using it as above to make sure it works right using static data, and not variables.it might be the variable giving you grief. Quote Link to comment https://forums.phpfreaks.com/topic/8241-problem-with-phpmysql-select-statement/#findComment-30071 Share on other sites More sharing options...
kenrbnsn Posted April 24, 2006 Share Posted April 24, 2006 Do you have an "or die" clause on the mysql_query() function call? If not do something like:[code]<?php$results = mysql_query($sql) or die('There was a problem in the query: ' . $sql . '<br>' . mysql_error());?>[/code]Does any error print after you do the above?Ken Quote Link to comment https://forums.phpfreaks.com/topic/8241-problem-with-phpmysql-select-statement/#findComment-30090 Share on other sites More sharing options...
[email protected] Posted April 26, 2006 Author Share Posted April 26, 2006 I have managed to fix itthanx Quote Link to comment https://forums.phpfreaks.com/topic/8241-problem-with-phpmysql-select-statement/#findComment-30886 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.