Page 1 of 1

Help with saving a color

Posted: 11 Jul 2014, 00:36
by ParrotLand
Something's wrong with my code when saving an item. I not sure what is wrong. Can someone please help!!!! I'm new to this.

PHP:
<?php
mysql_connect("host","user","pass") or die();
mysql_select_db("database name") or print "word=Failed.&checklog=2";;

$usercheck = $_POST['username'];

$result = mysql_query("UPDATE users SET Color = '1' WHERE username='$usercheck' ");
if (!$result) {
die('Invalid query: ' . mysql_error());
}

Flash:
on (release) {
var newCol = 9;
_root.smartfox.setUserVariables({col:newCol, init:true});
_root.myAvatar.disc.gotoAndStop(newCol);
_root.whatColor = 9;

if (_root.username != "") {
loadVariablesNum("itemsave.php", 0, "POST");
_root.word = "Begin saving process";

}else{
_root.word = "Error";
}
_root.closeColor();
}

Also tested the MySQL by updating a user and it worked (Using the code, UPDATE users SET Color = '1' WHERE username='Test')
Thanks.

Re: Help with saving a color

Posted: 11 Jul 2014, 12:28
by rjgtav
Hi there,

It seems you aren't sending the necessary variables to the php file.
I'd suggest you to use the LoadVars class instead of using the loadVariablesNum method.
On the LoadVars class you have a send() method (if you only want to send data to php, but don't need to retrieve anything from it) and a sendAndLoad() method (which sends data and then downloads the response from the php).
For your scenario, it seems the send() method is enough.

For more information you can check here:
http://stackoverflow.com/questions/1739 ... lue-to-php

Hope this helps

Re: Help with saving a color

Posted: 13 Jul 2014, 20:43
by ParrotLand
Thanks rjgtav!