Connecting Tech Pros Worldwide Forums | Help | Site Map

Select records from mysql Table

Newbie
 
Join Date: Aug 2007
Posts: 2
#1: Sep 26 '07
I am tearing what is left of my hair out by their roots. What I can get to work in MySQL Command line the exact same thing I cannot get to work in a PHP/MySQL script.

Here is the command line MySQL query
SELECT accesscode FROM authorize_users WHERE (user_id = 'MagooW' AND user_password = 'qwerty' and account = '46815185'; (it works accesscode 86190185 is reurned).

Here is the PHP/MySQL script command (using the same info )
Expand|Select|Wrap|Line Numbers
  1. $query = "SELECT access_code INTO $access FROM authorised_users
  2. WHERE (user_id =  $userid AND user_password = $password AND
  3. account = $account)";
  4. $result = $db->query($query);
  5. $db->close();
  6. echo ('$access after SELECT = '  . $access . "<BR><BR>"); ?>
  7.  
  8. $access = 0.
  9.  

ak1dnar's Avatar
Moderator
 
Join Date: Jan 2007
Location: Colombo
Posts: 1,440
#2: Sep 26 '07

re: Select records from mysql Table


Thread moved to the Php Forum from the Cafe.
With a new thread title instead of "Can anybody help??"

Please, post the technical questions, in the relevant forums.

Back to the question
well, where is the class and its methods?
Newbie
 
Join Date: Sep 2007
Location: indonesia
Posts: 25
#3: Sep 26 '07

re: Select records from mysql Table


Quote:

Originally Posted by X9183

I am tearing what is left of my hair out by their roots. What I can get to work in MySQL Command line the exact same thing I cannot get to work in a PHP/MySQL script.

Here is the command line MySQL query
SELECT accesscode FROM authorize_users WHERE (user_id = 'MagooW' AND user_password = 'qwerty' and account = '46815185'; (it works accesscode 86190185 is reurned).

Here is the PHP/MySQL script command (using the same info )

Expand|Select|Wrap|Line Numbers
  1. $query = "SELECT access_code INTO $access FROM authorised_users
  2. WHERE (user_id =  $userid AND user_password = $password AND
  3. account = $account)";
  4. $result = $db->query($query);
  5. $db->close();
  6. echo ('$access after SELECT = '  . $access . "<BR><BR>"); ?>
  7.  
  8. $access = 0.
  9.  

may be should be like this:
Expand|Select|Wrap|Line Numbers
  1. $queri="SELECT accesscode FROM authorize_users WHERE user_id = '$_POST(thenameofyourtextfield/radiobutton/etc whichcatch the value of user id)' AND user_password = '$_POST(thenameofyourtextfield/radiobutton/etc which catch the value of user's password)' and account = $_POST(thenameofyourtextfield/radiobutton/etc which catch the value of user's account)' ";
  2. $result=mysql_query($queri);
  3.  
  4.  
  5.  
we assumed that you use the POST method here..
hope that was clear
Reply