Quote:
Originally Posted by captainmerton
Am i losing my mind? The following mysql query seems to fail even though i am running it outside of the PHP code and its working fine. An echo statement shows that the select variables are being populated as expected. can anyone advise?
[PHP]
$userid = $_POST['userid'];
$password = $_POST['password'];
$getuser = "SELECT UserID,Password FROM User WHERE UserID = '$userid' AND Password = '$password'";
$userlogin=mysql_query($getuser);
while ($row = mysql_fetch_array($userlogin)) {
$loginid = $row['UserId'];
$loginpwd = $row['Password']; }
if (!$userlogin) {
exit('<p>There was a problem recalling your user details<p>');
}
[/PHP]
This coding is working perfectly with my Tables.
[PHP]<?php
require 'dbcon.php';
$userid = 1;
$password = 'Mike';
$getuser = "SELECT region,staffid FROM users WHERE id = '$userid' AND firstname = '$password'";
$userlogin=mysql_query($getuser) or die (mysql_error());
while ($row = mysql_fetch_array($userlogin))
{
echo $loginid = $row['region'];
echo $loginpwd = $row['staffid'];
}
if (!$userlogin)
{
exit('<p>There was a problem recalling your user details<p>');
}
?>[/PHP]
with some sample values to the POST Strings. if there you getting a problem check your HTML form also.
You can do it by simply echoing the POST strings and also the Sql String.
[PHP]echo $userid;
echo $password;
echo $getuser;
[/PHP]