Job3K.com |
| The only bookmark you need for oDesk, GetACoder, Freelancer, Guru, LimeExchange and others |
| Jobs posted today: 2954, yesterday: 5023 total: 2403910 |
|
|
Trouble deleting Mysql references through Unity WWW class |
|
| bid on the project | ||
| Date posted: 22-02-2012 23:48:28 Budget: $35 | ||
|
I am having trouble sending www forms from Unity3D to a perl script with instructions to
delete a reference from a Mysql database. I can add values no problem but when either
using perpare -> execute or do() I cannot get the references to delete. Please see the
Perl script below and the Unity script underneath. I can send a link to the full project if needed. __________________ Perl code: #!/usr/bin/perl use strict;#next three dh use CGI; use DBI; use DBD::mysql; print "Content-type: text/html \n\n"; # Read form data etc. dh my $cgi = new CGI; my $action = $cgi->param('action'); my $email = $cgi->param('email'); my $player = $cgi->param('player'); my $score = $cgi->param('score'); # MYSQL CONFIG VARIABLES my $platform = "mysql"; my $host = "xxxxxx.com"; my $database = "xxxxxx"; my $port = "3306"; my $tablename = "highscores"; my $user = "xxxxxx"; my $pw = "xxxxxx"; # DATA SOURCE NAME my $dsn = "DBI:$platform:$database:$host:$port"; # PERL MYSQL CONNECT() my $dbh = DBI->connect($dsn, $user, $pw); if($action eq "addValue"){ #my $query = "DELETE FROM highscores WHERE score NOT IN (SELECT score FROM (SELECT score FROM highscores ORDER BY score ASC LIMIT 9) foo)"; #my $query_handler = $dbh->prepare($query); #$query_handler->execute(); my $query = "INSERT INTO $tablename (email, player, score) VALUES (?, ?, ?)"; my $query_handler = $dbh->prepare($query); $query_handler->execute($email,$player,$score); $dbh->disconnect; } # PROBLEM - Delete not working if($action eq "deleteValue"){ #my $testit = "test@test"; # this causes an error, but not when I remove the '@' symbol. Why?? #$dbh->do("DELETE FROM highscores WHERE player = 'Johnny'"); # this works #my $testname = "Johnny"; #$dbh->do("DELETE FROM highscores WHERE player = $testname"); # this creates an error #$dbh->do("DELETE FROM highscores WHERE email = 'test@test.com'"); # this doesn't work #$dbh->do("DELETE FROM highscores WHERE player = $player"); # this Doesn't work $dbh->disconnect; } _________________________ Unity code: public IEnumerator ReplaceScore(string player, string email, float score) { var form = new WWWForm(); form.AddField( "action", "deleteValue" ); form.AddField( "player", player );//DH form.AddField( "email", email ); WWW download = new WWW( highscore_url, form ); yield return download; } |
||
| Keywords: player dbh score delete email highscores cgi mysql form action | ||