walkineagle Posted December 2, 2011 Share Posted December 2, 2011 <?php $verificate = $_GET["ver"]; $username = $_GET["user"]; $password = $_GET["pass"]; $dbh = mysql_connect("localhost","XXXXXX_dtbusre","my database password here") or die(mysql_error()); mysql_select_db("databasename_zxq_dtb") or die(mysql_error()); $sql = "SELECT loggedin FROM entityTable WHERE username=$username"; $result = mysql_query($sql) or die(mysql_error()); while ($line = mysql_fetch_array($result)){ echo $line[0]."\t".$line[1]."\n"; } mysql_close($dbh); if($verificate === "144356455343"){ echo "SURE"; } else{ echo "NOPE"; } ?> I get this: 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 '' at line 1 Quote Link to comment https://forums.phpfreaks.com/topic/252280-mysql-newbie-php-help-needed/ Share on other sites More sharing options...
Glese Posted December 2, 2011 Share Posted December 2, 2011 I am a new comer myself. But from what I can see, try to rewrite it like this: $dbh = mysql_connect("localhost","XXXXXX_dtbusre","my database password here", "databasename_zxq_dtb" ); $sql = "SELECT loggedin FROM entityTable WHERE username = '{$username}'"; $result = mysql_query($dbh, $sql) or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/252280-mysql-newbie-php-help-needed/#findComment-1293365 Share on other sites More sharing options...
awjudd Posted December 2, 2011 Share Posted December 2, 2011 As Glese said, since your username is a string, you need to enclose it in single quotes in your query otherwise the database will think you are comparing two fields. ~awjudd Quote Link to comment https://forums.phpfreaks.com/topic/252280-mysql-newbie-php-help-needed/#findComment-1293368 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.