I can't seem to post needed information to my database, here's what I've got:
<mx:HTTPService id="someService" url="http://name.domain/postPHP.php" method="POST">
<s:request xmlns="">
<name>{name.text}</name>
<score>{score.text}</score>
</s:request>
</mx:HTTPService>
And of course a button to send开发者_如何学编程();
Php as follows:
echo "<?xml version=\"1.0\" ?>\n;
$connections = ...;
mysql_select_db("...");
$name = $_POST['name'];
$score = $_POST['score'];
$query = "INSERT INTO hs (name, score) VALUES ('$name', '$score')";
mysql_query($query);
So what is wrong? Why ain't it adding the information to my database?
Thanks, Yan
Missing a " at the end of the first line:
echo "<?xml version=\"1.0\" ?>\n";
$connections = ...;
mysql_select_db("...");
$name = $_POST['name'];
$score = $_POST['score'];
$query = "INSERT INTO hs (name, score) VALUES ('$name', '$score')";
mysql_query($query);
In these simple examples, I guess it is ok to use raw sql directly to the mysql function libraries...
However, it's so simple to use PDO, and not deal with all the security BS, lack of portability, etc..
Here is how you use a prepared statement
Just do it that way, and avoid having to learn about mysql_real_escape_string and all the rest of the crap, then having to relearn PDO...
Couldn't accept @grossvogel comment as an answer, but that is in fact correct, all was missing is that close-quote.. Many thanks to all!
echo "<?xml version=\"1.0\" ?>\n";
$connections = ...;
mysql_select_db("...");
$name = $_POST['name'];
$score = $_POST['score'];
$query = "INSERT INTO hs (name, score) VALUES ('$name', '$score')";
mysql_query($query);
精彩评论