Results 1 to 2 of 2

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

  1. #1
    Join Date
    Sep 2010

    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");

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

  2. #2
    Join Date
    Aug 2004
    $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.
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

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