Page 1 of 1

Flex login app help

Posted: Wed May 07, 2008 2:03 am
by corbo950
I have a adobe AIR application and I wanted to add a login script to it. So this is what I came up with and I can't figure out why it wouldn't return anything(blank no errors). Help would be much appreciated.

Code: Select all

   <?php
          $dbhost = '127.0.0.1';
          $dbuser = 'root';
          $dbpass = '1111';
          $dbname = 'flex';
       
       $conn = sprintf("mysql_pconnect('%s', '%s', '%s')", $dbhost, $dbuser, $dbpass);
       if (!$conn)
          {
             exit("Unable to connect to DB: " . mysql_error());
          }
       
       if (!sprintf("mysql_select_db('%s')", $dbname))
          {
             exit("Unable to select mydbname: " . mysql_error());
          }
          
       $users = cw_sql_query('SELECT * FROM volunteer_users');
       while(list($pos, $user)=each($users))
       {
          if($_REQUEST["username"]=$user["username"])
          {
             if($_REQUEST["password"]=$user["password"])
             {
                   echo("1");
             }
             else
             {
                echo("0");
             }
          }
          else
          {
             echo("0")
          }
       }
       function cw_sql_query($info)
       {
          global $conn;
          $query = mysql_query($info);
          dump($query);
          $results = array();
          while ($result = mysql_fetch_assoc($query))
          {   
             
             array_push($results, $result);
          }
          mysql_free_result($query);
          Return($results);
       }
       
    ?>
 

Re: Flex login app help

Posted: Wed May 07, 2008 5:47 pm
by Jade
Okay, your first mistake is including your login and password to your server in a public forum. Shame on you! Even if you are running it on localhost.

Second I have no idea why you're doing some kind of query within a function thing. Try something like this:

Code: Select all

 
<?php
$dbhost = '127.0.0.1';
$dbuser = 'root';
$dbpass = 'nope';
$dbname = 'blah';
 
$conn = sprintf("mysql_pconnect('%s', '%s', '%s')", $dbhost, $dbuser, $dbpass);
        if (!$conn)
           {
              exit("Unable to connect to DB: " . mysql_error());
           }
        
        if (!sprintf("mysql_select_db('%s')", $dbname))
           {
              exit("Unable to select mydbname: " . mysql_error());
           }
          
        $result = mysql_query('SELECT * FROM volunteer_users')
        or die ('there was an error: ' . mysql_error());
 
        while($user = mysql_fetch_array($result))
        {
           if($_REQUEST["username"]=$user["username"])
           {
              if($_REQUEST["password"]=$user["password"])
                    echo("1");
              else
                 echo("0");
           }
           else
              echo("0")
        } //end while
 
     mysql_free_result($result);
        
    ?>
 

Re: Flex login app help

Posted: Thu May 08, 2008 1:58 pm
by corbo950
1. it is a testing server and i have the default mysql username and password in there.
2. the function is copyied from my framework since i use querys all the time i just didnt want to post both separatly on here
3. i fixed it thanks anyway though