I have created a web service using PDO's in PHP, as seen here.:
<?php
session_start();
try {
$dbh = new PDO("serverhere;dbname=DBhere",'userhere', 'passwordhere');
} catch (PDOException $e)
{
echo $e->getMessage();
}
if ($_POST['user'] != null and $_POST['user'] != "" && $_POST['password'] != null and $_POST['password'] != "")
{
$username = $_POST['user'];
$password = $_POST['password'];
echo '$_POST[user] = '. $_POST['user']."<br/>";
echo '$_POST[password] = '.$_POST['password']."<br/>";
echo 'username = '.$username."<br/>";
echo 'password = '.$password."<br/>";
//$sth = $dbh->prepare("SELECT * FROM users");
$sth = $dbh->prepare("SELECT * FROM users WHERE email=:username and password= :password");
$sth->bindParam(":username", $username);
$sth->bindParam(":password", $password);
echo "<br/>";
print_r($sth);
echo "<br/>";
$sth->execute();
//print_r($sth);
$result = $sth->fetchAll();
print_r($result);
//$sth1 = $dbh->query("SELECT * FROM users");
/*echo "<br/>";
echo $result[0];
echo $result[0]->{'COUNT(*)'};*/
} else
{
echo "I went to the else";
echo "-". $_POST['user'];
echo "-".$_POST['password'];
}
?>
To consume the web service in php I have this HTML form:
<html>
<body>
<form method="POST" action="http://someservice.php">
Username: <input type="text" name="user" size="15" /><br />
Password: <input type="password" name="password" size="15" /><br />
<div align="center">
<p><input type="submit" value="Login" /></p>
</div>
</form>
</body>
</html>
When using this HTML form I get the following results for user=hey, and password=guy (a test account I have in MySQL)
heyguyheyguyjustb4query PDOStatement Object ( [queryString] => SELECT * FROM users WHERE email=:username and password= :password ) Array ( [0] => Array ( [UserID] => 2 [0] => 2 [email] => hey [1] => hey [password] => guy ) )
Now in Silverlight I get this response to the same values:
heyguy
heyguy
justb4query<br/>PDOStatement Object
(
[queryString] => SELECT * FROM users WHERE email=:username and password= :password
)
<br/>Array
(
)
Now I originally assumed that something in the .net framework was not getting the response back properly, but I decided to test this first:
So I rewrite the SQL and remove the variables changing:
This:
SELECT * FROM users WHERE email=:username and password= :password
To this:
SELECT * FROM users
Now my results in the HTML form are this:
$_POST[user] = hey $_POST[password] = guy username = hey password = guy PDOStatement Object ( [queryString] => SELECT * FROM users ) Array ( [0] => Array ( [UserID] => 2 [0] => 2 [email] => hey [1] => hey [password] => guy [2] => guy)
Targeting that same web service in Silverlight I get this:
$_POST[user] = hey<br/>$_POST[password] = guy
<br/>username = hey<br/>password = guy
<br/><br/>PDOStatement Object
(
[queryString] => SELECT * FROM users
)
<br/>Array
(
[0] => Array
(
[UserID] => 2
[0] => 2
[email] => hey
[1] => hey
[password] => guy
[2] => guy
)
So now I am not sure what is hindering my SQL statement that has a WHERE clause, if you have any idea PLEASE let me know, I really appreciate it!

New Topic/Question
This topic is locked



MultiQuote






|