views:

32

answers:

3

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

A: 

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...

Zak
A: 

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);
Eton B.
lolcats... double quotes enclose the string in many of the cases... bad bad bad, but I won't downvote you if you fix it.
Zak
I'm assuming it's all one big echo
Eton B.
What errors are you getting?
Eton B.
A: 

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);
Yan