Problem en j2me

salihou_dev Messages postés 6 Date d'inscription lundi 1 décembre 2014 Statut Membre Dernière intervention 19 février 2019 - Modifié par BunoCS le 9/01/2015 à 09:47
BunoCS Messages postés 15472 Date d'inscription lundi 11 juillet 2005 Statut Modérateur Dernière intervention 25 mars 2024 - 9 janv. 2015 à 09:48
Bonjour, 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 :
<?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:
<?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 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
      $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 .= "</$key>";
      }
      $xml.="</utilisateur>";
   }
//close the root element
$xml .= "</$root_element>";
//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

1 réponse

BunoCS Messages postés 15472 Date d'inscription lundi 11 juillet 2005 Statut Modérateur Dernière intervention 25 mars 2024 103
9 janv. 2015 à 09:48
Hello,

J'ai rajouté les balises code pour plus de lisibilité, voir ici. Penses-y la prochaine fois ^^
0
Rejoignez-nous