Click to See Complete Forum and Search --> : [RESOLVED] Simple Select statement...


TehShlocker
06-25-2006, 11:45 AM
Okay This is a very simple problem, I just don't know how to fix it... Here's my Query:
SELECT Password,MemberName FROM members WHERE MemberName = "$Mebr" and Password = "$Pswd"
when $Mebr and $Pswd were set earlier vie a $_Post script:
$Pswd=$_Post["Pswd"];
$Mebr=$_Post["Mebr"]; $Mebr = strtolower($Mebr);
The Problem is, when the query is submitted it goes through succesfully, but instead of Comparing MemberName to whatever the $Mebr is, it literally Compares MemberName to "$Mebr"... and the same with Password and $Pswd.
I just started SQL and PHP Yesterday (You prolly have seen my other posts...) so I'm sure this is some simple problem with a simple fix, I just can't figure it out. :D

russell
06-25-2006, 11:52 AM
would need to see the php generating the query, but ought to be like this

$sql = "SELECT Password,MemberName FROM members WHERE MemberName = '".$Mebr ."' and Password = '". $Pswd ."'";

TehShlocker
06-25-2006, 11:56 AM
after doing that, the query showed that is was comparing poth MemberName and Password to "

Here's the php in a whole:
<?php

//Set variables
$Pswd=$_Post["Pswd"];
$Mebr=$_Post["Mebr"]; $Mebr = strtolower($Mebr);
$hostname="mysql141.secureserver.net";
$username="TehShlocker"; $passwrd="*****";
$dbname="TehShlocker"; $tbname="members";
$query="SELECT Password,MemberName FROM members WHERE MemberName = '".$Mebr."' and Password = '".$Pswd."' ";

//Connect to Database
mysql_connect($hostname,$username, $passwrd) OR DIE ("Unable to connect to database! Please try again later.");
mysql_select_db($dbname) OR DIE ("Unable to select to Database! Please try again later.");
$result = mysql_query($query) OR DIE (mysql_error());
echo "Query Succesful: $query\n";
$num_rows = mysql_num_rows($result);
echo "$num_rows Rows\n";
?>
See if that helps clear things up or not.... :cool:

russell
06-25-2006, 03:02 PM
and if you echo $Mebr and $Pswd ?

TehShlocker
06-25-2006, 03:06 PM
It won't echo or if it does it echos nothing.

chazzy
06-26-2006, 11:48 AM
at the top, before you set the values, add:

print_r($_POST);

aussie girl
07-01-2006, 12:01 AM
OOPS didn't see RESOLVED my bad..

what about..

$Pswd=$_Post['Pswd'];
$Mebr=$_Post['Mebr']; $Mebr = strtolower($Mebr);

$query="SELECT Password,MemberName FROM members WHERE MemberName = '$Mebr' and Password = '$Pswd' ";

are you using any encryption on your password