Hello, How can I have sure my var goes to php? I'm querying a mysql database, but I can't find the error, since I get in flash the result (but the wrong results), so I assume that php isn't receiving the var. I have a button which declares the var - _global.Myvar = this._parent.text; (this button is inside a textfild img src) Then I have my main timeline which declares - MyVar = _global.Myvar and lv.sendAndLoad("pormenores.php", lv, "POST"); In php I have: Nome = $_POST["MyVar"]; $query = "SELECT *, MATCH (Nome) AGAINST ('$Nome') FROM contactos" As a result, I get all the records I have in database, but they aren't the one of MyVar but the first ones from DB (ID=1) Any sugestion?
if php is case sensitive you'll have a problem. use:
Hello Kglad, how do you do? no, that was not the problem...
try sv = new LoadVars(); sv.MyVar = _global.Myvar; lv = new LoadVars(); lv.onLoad=function(){trace(unescape(this));}; sv.sendAndLoad("pormenores.php", lv, "POST");
Hi, Jack, I just feel bad for asking you questions... You're always helping me :-) Thanks man! But, know I'm unable to add that portion of code into what I've already. Here he his, can you please "atach" him to me? Thanks! stop(); searchfield = _global.Nome; lv = new LoadVars(); trace(lv); lv.onLoad = function() { str1 = unescape(this).split("\r\n").join("|"); nomes = str1.split("|-----|"); for (var iv = 0; iv<nomes.length; iv++) { nomes[iv] = nomes[iv].split("|"); } nomes.pop(); tracer(); }; lv.sendAndLoad("Phps_Txts/pormenores.php", lv, "POST"); function tracer() { for (var iv = 0; iv<nomes.length; iv++) { trace("---"); for (var jv = 0; jv<nomes[0].length; jv++) { trace("nomes["+iv+"]["+jv+"] - "+nomes[iv][jv]); if (nomes[0][0] == undefined) { Nome.text == ""; } else { Nome.text = nomes[0][0]; } if (nomes[0][1] == undefined) { Morada.text == ""; } else { Morada.text = nomes[0][1]; } if (nomes[0][2] == undefined) { Codpostal.text == ""; } else { Codpostal.text = nomes[0][2]; } if (nomes[0][3] == undefined) { Localidade.text == ""; } else { Localidade.text = nomes[0][3]; } if (nomes[0][4] == undefined) { Telefone.text == ""; } else { Telefone.text = nomes[0][4]; } if (nomes[0][5] == undefined) { Fax.text == ""; } else { Fax.text = nomes[0][5]; } if (nomes[0][6] == undefined) { Telemovel.text == ""; } else { Telemovel.text = nomes[0][6]; } if (nomes[0][7] == undefined) { Email.text == ""; } else { Email.text = nomes[0][7]; } if (nomes[0][8] == undefined) { Website.text == ""; } else { Website.text = nomes[0][8]; } if (nomes[0][9] == undefined) { Nipc.text == ""; } else { Nipc.text = nomes[0][9]; } if (nomes[0][10] == undefined) { Empresa.text == ""; } else { Empresa.text = nomes[0][10]; } if (nomes[0][11] == undefined) { Cargo.text == ""; } else { Cargo.text = nomes[0][11]; } if (nomes[0][12] == undefined) { MoradaEmpresa.text == ""; } else { MoradaEmpresa.text = nomes[0][12]; } if (nomes[0][13] == undefined) { CodigoPostalempresa.text == ""; } else { CodigoPostalempresa.text = nomes[0][13]; } if (nomes[0][14] == undefined) { LocalidadeEmpresa.text == ""; } else { LocalidadeEmpresa.text = nomes[0][14]; } if (nomes[0][15] == undefined) { TelefoneEmpresa.text == ""; } else { TelefoneEmpresa.text = nomes[0][15]; } if (nomes[0][16] == undefined) { FaxEmpresa.text == ""; } else { FaxEmpresa.text = nomes[0][16]; } if (nomes[0][17] == undefined) { TelemovelEmpresa.text == ""; } else { TelemovelEmpresa.text = nomes[0][17]; } if (nomes[0][18] == undefined) { EmailEmpresa.text == ""; } else { EmailEmpresa.text = nomes[0][18]; } if (nomes[0][19] == undefined) { WebsiteEmpresa.text == ""; } else { WebsiteEmpresa.text = nomes[0][19]; } if (nomes[0][20] == undefined) { NipcEmpresa.text == ""; } else { NipcEmpresa.text = nomes[0][20]; } if (nomes[0][21] == undefined) { InformacaoAdicional.text == ""; } else { InformacaoAdicional.text = nomes[0][21]; } } } }
where you have - searchfield = _global.Nome;
yes, I am. _global.Nome was defined in my button.swf. tgt["txt"+iv].htmlText += ""+arr[iv]+""+'<img src="botao.swf" vspace ="-12" hspace="0" id="botao">'+"</a>"; this gives me all the names, and atach a button to each, whith this code: on (press) { _global.Nome = this._parent.text; } I'm assuming that this variable is at all the timelines, write?
if your php is expecting - Nome = $_POST["MyVar"]; adapt the code i sent as - trace(_global.Nome); // does it exist ? sv = new LoadVars(); // sv = vars to send to php sv.MyVar = _global.Nome; // send variable MyVar // (it holds the value of _global.Nome) to the php lv = new LoadVars(); // lv = vars received from php lv.onLoad=function(){trace(unescape(this));}; sv.sendAndLoad("pormenores.php", lv, "POST"); hth
I just don't get it. The trace gives me the result I want, but the var isn't passing to php... If you don't mind, I'm puting the files in www.esquisso.com/jack/Jack.zip Can you please check if i'm doing something wrong? Many thanks Jack! Pluda
sorry Pluda, but i do not have enough time to sort out your project, can i suggest that you open a new fla and get it communicating with a simple php file. when this is working, try bringing your DB into play. when you are happy that all is OK, tranfer the logic into your main project.
Don't see what you're looking for? Try a search.
|