Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query after login not working - mySQL

Status
Not open for further replies.

sbayter

IS-IT--Management
Nov 14, 2002
95
0
0
CO
Hi,
I'm creating a simple login page which goes into another page displaying the query for the user that logged in.
The problem is that it doesn't show anything and when i take out "[red]WHERE EMAIL = '$email'[/red]" it displays all the table in the DB and I only want it to show the row related to the email.

This is how the query looks like:

$email=$HTTP_POST_VARS['email'];
mysql_select_db($database_myConn, $myConn);
$query_myRs = "SELECT * FROM request [red]WHERE EMAIL = '$email'[/red] ";


Thanks,



sbayter
 
Go through the standard debugging steps:

Output your query (with the WHERE clause) to the browser. Does it look correct by visual inspection?

Copy and paste the query string into your preferred MySQL admin tool. Do you get correct results there?

Want the best answers? Ask the best questions: TANSTAAFL!
 
I doesn't work.
however when I replace the $email with any name it works. Just like this:

$query_myRs = "SELECT * FROM request WHERE EMAIL = 'John.Smith@domain.com' ";

It should be the way I'm getting the value from the form in the page or maybe how I'm calling it in the "WHERE EMAIL = '$email'";

What do you think?

Thanks,



sbayter
 
"It doesn't work" is completely unhelpful to me.

The fact that you have a variable named $email that does not contain the value you expect is completely unhelpful to me, too.

Where is the value getting into that variable? Are you expecting a form field to submit that value? If so, do you have register_globals turned on?

Want the best answers? Ask the best questions: TANSTAAFL!
 
sleipnir214,
I'm sorry, I'm just starting with php, there's no reson to get angry.
I'm sorry for my ignorance with php.

I checked and the register_globals are on.

What I have is a first page with only on text field (called email). When one types an email and submits I want the next page to show kind of like a history of that person.

I don't know how to get that value of email and use it in the query.

Sorry and thanks again,


sbayter
 
I'm not angry -- trust me, you'd know. I'm only irritated -- it's difficult to help when you are asking questions about the functioning of your script that are unknown to anyone in this forum.

If register_globals is set to "on", then the value of a form input named "email" should be available in a variable named "$email" when the form is submitted.

Some things to check:

Do your form element name and your referenced variable name match exactly, keeping in mind that PHP variable names are case-specific?

Does the value appear in the PHP global or superglobal arrays? POST-method and GET-method form variables will always appear in the superglobal arrays $_POST and $_GET, respectively, for verions of PHP >= 4.1.0. For older versions of PHP take a look in $HTTP_POST_VARS or $HTTP_GET_VARS, respectively. (
A useful tool in viewing the contents of arrays is print_r() (
Want the best answers? Ask the best questions: TANSTAAFL!
 
Just make a check on it.

Visually to satisfy yourself you can first echo the $email to the browser just to know if it exist. And the real check should be;

if($email && ($email != "")){
proceed with your query...
}else{
show error which mean the $email is empty.
}

Many other ways to do this but as long it work who cares?
 
perhaps there's an extra space or the email typed is not exactly the same. MySQL is not case sensitive so if you put

'john.smith@domain.com' = 'JOHN.SMITH@DOMAIN.COM' it should come out.

Try echo "-".$email."-"; and see if it has any extra spacing or whatever

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top