ShiloVir Posted November 26, 2008 Share Posted November 26, 2008 This is the code im using: <?php $sql = mysql_real_escape_string("SELECT f_name, l_name, airline_id, callsign FROM auth_users WHERE airline_id = '".$_POST["airline_id"]."' AND password = PASSWORD('".$_POST["password"]."')"); $result = mysql_query($sql, $conn) or die(mysql_error()); ?> and its giving me this error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '\r\n\'sva\' AND password = PASSWORD(\mehpassword\')' at line 1 Link to comment https://forums.phpfreaks.com/topic/134313-solved-you-have-an-error-in-your-sql-syntax-what-where/ Share on other sites More sharing options...
dezkit Posted November 26, 2008 Share Posted November 26, 2008 Are you trying to pass a function inside the query? Link to comment https://forums.phpfreaks.com/topic/134313-solved-you-have-an-error-in-your-sql-syntax-what-where/#findComment-699247 Share on other sites More sharing options...
ShiloVir Posted November 26, 2008 Author Share Posted November 26, 2008 IM trying to do what it says above. haha, sorry. Ima Newbie and dont know what u mean. if you stating... am I trying to pass $_POST['']; variables in a query then the answer is "yes"! Link to comment https://forums.phpfreaks.com/topic/134313-solved-you-have-an-error-in-your-sql-syntax-what-where/#findComment-699250 Share on other sites More sharing options...
PFMaBiSmAd Posted November 26, 2008 Share Posted November 26, 2008 You don't apply mysql_real_escape_string() to the query string, you apply it to the pieces of data within the query string. Link to comment https://forums.phpfreaks.com/topic/134313-solved-you-have-an-error-in-your-sql-syntax-what-where/#findComment-699269 Share on other sites More sharing options...
ShiloVir Posted November 26, 2008 Author Share Posted November 26, 2008 haha. oops! Ima dummy. I knew that too! Why did I do that?? TOPIC SOLVED!! (I need some coffee) Link to comment https://forums.phpfreaks.com/topic/134313-solved-you-have-an-error-in-your-sql-syntax-what-where/#findComment-699270 Share on other sites More sharing options...
ShiloVir Posted November 26, 2008 Author Share Posted November 26, 2008 This works: <?php $sql = "SELECT f_name, l_name, airline_id, callsign FROM auth_users WHERE airline_id = '".mysql_real_escape_string($_POST["airline_id"])."' AND password = PASSWORD('".mysql_real_escape_string($_POST["password"])."')"; $result = mysql_query($sql, $conn) or die(mysql_error()); ?> Thanks guys! Link to comment https://forums.phpfreaks.com/topic/134313-solved-you-have-an-error-in-your-sql-syntax-what-where/#findComment-699272 Share on other sites More sharing options...
PFMaBiSmAd Posted November 26, 2008 Share Posted November 26, 2008 Don't use the mysql PASSWORD() function in your application - The PASSWORD() function is used by the authentication system in MySQL Server; you should not use it in your own applications. The hash used by the PASSWORD() function has been changed on occasions, resulting in broken applications by those who used it against the recommendations of mysql. Link to comment https://forums.phpfreaks.com/topic/134313-solved-you-have-an-error-in-your-sql-syntax-what-where/#findComment-699275 Share on other sites More sharing options...
ShiloVir Posted November 26, 2008 Author Share Posted November 26, 2008 so what do I use now instead of it? I need a hash in my database. I cant leave that unsecured Link to comment https://forums.phpfreaks.com/topic/134313-solved-you-have-an-error-in-your-sql-syntax-what-where/#findComment-699281 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.