问题和问题 [英] Probleme en j2me

查看:95
本文介绍了问题和问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

j'aicherchéunesolutionàmaprobleme depuis 5 jours

si quelqu'un peux m'aider

j'ai fait une authentification en j2me le probleme est àwindde la connection



si j'ecris url dans le navigateur il marche mais si je test avec wireless toolkit il affiche un erreurImpossible d'etablir la connection (例外)



voici mes code



connect.php:



$ hostname_localhost =localhost;

$ database_localhost =virtual_university;

$ username_localhost =root;

$ password_localhost =;

$ con = mysql_connect($ hostname_localhost,$ username_localhost,$ password_localhost)



trigger_error(mysql_error(),E_USER_ERROR);

?>







authentif.php:



require_once('connect.php');

$ mail = $ _GET ['email'];

$ mdp = $ _GET ['pwd'];

mysql_select_db($ database_localhost ,$ CON);

$ query_search =SELECT * FROM utilisateur WHERE email LIKE'$ mail'AND password LIKE'$ mdp';;

$ query_exec = mysql_query($ query_search)或die(mysql_error());

if($ query_exec!= null){

$ xml =;

$ root_element =utilisateur;

$ xml。=< $ root_element>;

while($ result_array = mysql_fetch_assoc($ query_exec))

{

$ xml。=< utilisateur>;

foreach($ result_array as $ key => $ value)

{

// $ key保存表列名称

$ xml。=< $ key>;

//将SQL数据嵌入到CDATA元素避免XML实体问题

$ xml。=<![CDATA [$ value;

//并关闭元素

$ xml。=;

}

$ xml。= ;

}

//关闭根元素

$ xml。=;

/ /将xml标题发送到浏览器

标题(Content-Type:text / xml);

//输出XML数据

echo $ xml;

}

?>







dans le midlet:



public void commandAction(命令c,可显示的d){

if((c == Signin)&&&(d == formauth)){

Thread t = new Thread(new Runnable(){

public void run(){

try {

PersonH​​andler personH​​and = new PersonH​​andler();

String urlauth =http://localhost/parsing/authentif.php?email =+ tf_authmail.getString()+& pwd =+ tf_authMdp.getString();

SAXParser解析器= SAXParserFactory.newInstance()。newSAXParser();

HttpConnection hc =(HttpConnection)Connector.open(urlauth);

DataInputStream dis = new DataInputStream(hc.openDataInputStream());

parser.parse(dis,personH​​and);

util isateur = personH​​and.getPerson();

if(utilisateur.length!= 0){

clcurr = utilisateur [0];

tb .setString(clcurr.getNom());

disp.setCurrent(form);

// disp.setCurrent(lst);

// disp.setCurrent(new CanvasMenu());

} else {

Alert al = new Alert(ERROR,verifiezvosdonnées,null,AlertType .INFO);

disp.setCurrent(al);

}

} catch(例外e){

disp.setCurrent(new Alert(Error,Impossible d'etablir la connection,null,AlertType.ERROR),formauth);

}

}

});

t.start ();

}





et merci d'avance

j'ai cherché une solution à ma probleme depuis 5 jours
si quelqu'un peux m'aider
j'ai fait une authentification en j2me le probleme est à cause de la connection

si j'ecris url dans le navigateur il marche mais si je test avec wireless toolkit il affiche un erreur "Impossible d'etablir la connection" (Exception)

voici mes codes

connect.php :

$hostname_localhost ="localhost";
$database_localhost ="virtual_university";
$username_localhost ="root";
$password_localhost ="";
$con = mysql_connect($hostname_localhost,$username_localhost,$password_localhost)
or
trigger_error(mysql_error(),E_USER_ERROR);
?>



authentif.php:

require_once('connect.php');
$mail= $_GET['email'];
$mdp= $_GET['pwd'];
mysql_select_db($database_localhost,$con);
$query_search = "SELECT * FROM utilisateur WHERE email LIKE '$mail' AND password LIKE '$mdp';";
$query_exec = mysql_query($query_search) or die(mysql_error());
if($query_exec!=null){
$xml = "";
$root_element = "utilisateur";
$xml .= "<$root_element>";
while($result_array = mysql_fetch_assoc($query_exec))
{
$xml .= "<utilisateur>";
foreach($result_array as $key => $value)
{
//$key holds the table column name
$xml .= "<$key>";
//embed the SQL data in a CDATA element to avoid XML entity issues
$xml .= "<![CDATA[$value";
//and close the element
$xml .= "";
}
$xml.="";
}
//close the root element
$xml .= "";
//send the xml header to the browser
header ("Content-Type:text/xml");
//output the XML data
echo $xml;
}
?>



dans le midlet :

public void commandAction(Command c, Displayable d) {
if ((c == Signin) && (d == formauth)) {
Thread t= new Thread(new Runnable() {
public void run() {
try {
PersonHandler personHand = new PersonHandler();
String urlauth = "http://localhost/parsing/authentif.php?email="+tf_authmail.getString()+"&pwd="+tf_authMdp.getString();
SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
HttpConnection hc = (HttpConnection) Connector.open(urlauth);
DataInputStream dis = new DataInputStream(hc.openDataInputStream());
parser.parse(dis, personHand);
utilisateur = personHand.getPerson();
if (utilisateur.length != 0) {
clcurr = utilisateur[0];
tb.setString(clcurr.getNom());
disp.setCurrent(form);
// disp.setCurrent(lst);
// disp.setCurrent(new CanvasMenu());
} else {
Alert al = new Alert("ERROR", "verifiez vos données", null, AlertType.INFO);
disp.setCurrent(al);
}
} catch (Exception e) {
disp.setCurrent(new Alert("Error", "Impossible d'etablir la connection", null, AlertType.ERROR), formauth);
}
}
});
t.start();
}


et merci d'avance

推荐答案

hostname_localhost =localhost;
hostname_localhost ="localhost";


database_localhost =virtual_university;
database_localhost ="virtual_university";


username_localhost =root;
username_localhost ="root";


这篇关于问题和问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆