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.
$id = filter_input(INPUT_POST, "Text1");
$sec= filter_input(INPUT_POST, "Text2");
$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 12:50 PM.
Reason: fixed syntax error in code (missing quote)
$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
How to Ask Questions the Smart Way
(not affiliated with this site, but well worth reading)
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)