Help with saving a color

Need help with SmartFoxServer? You didn't find an answer in our documentation? Please, post your questions here!

Moderators: Lapo, Bax

ParrotLand
Posts: 6
Joined: 08 Oct 2011, 15:11

Help with saving a color

Postby ParrotLand » 11 Jul 2014, 00:36

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.
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Re: Help with saving a color

Postby rjgtav » 11 Jul 2014, 12:28

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
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
ParrotLand
Posts: 6
Joined: 08 Oct 2011, 15:11

Re: Help with saving a color

Postby ParrotLand » 13 Jul 2014, 20:43

Thanks rjgtav!

Return to “SmartFoxServer 1.x Discussions and Help”

Who is online

Users browsing this forum: No registered users and 26 guests