www.webdeveloper.com
Results 1 to 2 of 2

Thread: Getting from $result to $user1 in a php SQL statement

  1. #1
    Join Date
    Sep 2010
    Posts
    64

    Getting from $result to $user1 in a php SQL statement

    How do you get $user1 from $result even if null?

    Text1 and Text2 are from the submit button from login.php and they do exist.

    I have a MySQL database: db12345, table: login, and columns: idl, secid and username.

    They exist.


    PHP Code:
                $id filter_input(INPUT_POST"Text1");
            
    $secfilter_input(INPUT_POST"Text2");

            
    $conn mysql_connect('server.com''dbo12345''pass1');
            
    mysql_select_db('db12345');
                
    $sql "SELECT `username` FROM `login` WHERE idl=".$id." And secid=".$sec.";";
            
    $result mysql_query($sql$conn);
            
    //$result->$user1
             
    mysql_close($conn); 
    Last edited by NogDog; 06-28-2014 at 12:50 PM. Reason: fixed syntax error in code (missing quote)

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,176
    $result will be a query result resource if successful, otherwise FALSE. You'll have to use one of the mysql_fetch_*() function to read a result row from that resource. Of course, you really shouldn't be using the deprecated mysql_*() functions at all, instead either using the MySQLi or PDO database extensions.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles