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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MySQL querys in pHp with Variables ?

Status
Not open for further replies.

maverick

MIS
Apr 21, 1999
193
US
Hello all !

Why is it, that this query won't work ?

MySQL created it for php, I just added the variables...

$sql = 'SELECT count( * ) '
. ' FROM users'
. ' WHERE name = "$name" AND pass = "$password"';

it should return 1

tia, this is bugging me !

--------------------------------------
"Hacker by Heart"
saenzcorp@hotpop.com
 
OK, here is the Query script that works for me

$select = "SELECT count(*)" ;
$from = " FROM users" ;
$where = " WHERE name='$one' and pass='$two' " ;
$query = $select . $from . $where ;

But it doesn't seem to work with:
if(!isset($_POST["name"])&&!isset($_POST["password"]))

or couold it be:
<h1>Please Log In</h1>
This page is secret.
<form method=post action="secretdb.php">
<table border = 1>
<tr>
<th> Username </th>
<td> <input type=text name=name> </td>
</tr>
<tr>
<th> Password </th>
<td> <input type=password name=password> </td>
</tr>
<tr>
<td colspan =2 align = center>
<input type = submit value = "Log In">
</td>
</tr>
</form>

this FORM stuff causing the problem ?

something seems to not be passing name and password to the query ?

tia :)


--------------------------------------
"Hacker by Heart"
saenzcorp@hotpop.com
 
Got it !

thanks all !!!!

--------------------------------------
"Hacker by Heart"
saenzcorp@hotpop.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top