mrt003003 Posted April 30, 2011 Share Posted April 30, 2011 Hello, Im trying to write a select query that has two conditions. First the playername is = username and second shipyard = 1 I keep getting a parse error: Parse error: syntax error, unexpected ',' in C:\wamp\www\SWB\planet1.php on line 85 Heres the code: $tester = "1"; $colname_Planet1 = "-1"; if (isset($_SESSION['MM_Username'])) { $colname_Planet1 = (get_magic_quotes_gpc()) ? $_SESSION['MM_Username'] : addslashes($_SESSION['MM_Username']); } mysql_select_db($database_swb, $swb); $query_Planet1 = ("SELECT * FROM planet WHERE ShipYard = %s AND PlayerName = %s", GetSQLValueString($tester, "int"),GetSQLValueString($colname_Planet1, "text")); $Planet1 = mysql_query($query_Planet1, $swb) or die(mysql_error()); $row_Planet1 = mysql_fetch_assoc($Planet1); $totalRows_Planet1 = mysql_num_rows($Planet1); Please help :| Quote Link to comment https://forums.phpfreaks.com/topic/235189-select-query-with-2-conditions/ Share on other sites More sharing options...
PFMaBiSmAd Posted April 30, 2011 Share Posted April 30, 2011 The syntax you are using in the line to build your query statement is that for a sprintf statement, but you don't have a sprintf() in your code. Quote Link to comment https://forums.phpfreaks.com/topic/235189-select-query-with-2-conditions/#findComment-1208639 Share on other sites More sharing options...
mrt003003 Posted April 30, 2011 Author Share Posted April 30, 2011 Yes! Thank you, ive been staring at it too long. Thanks again Quote Link to comment https://forums.phpfreaks.com/topic/235189-select-query-with-2-conditions/#findComment-1208640 Share on other sites More sharing options...
JKG Posted April 30, 2011 Share Posted April 30, 2011 <?php $tester = "1"; $colname_Planet1 = "-1"; if (isset($_SESSION['MM_Username'])) { $colname_Planet1 = (get_magic_quotes_gpc()) ? $_SESSION['MM_Username'] : addslashes($_SESSION['MM_Username']); } mysql_select_db($database_swb, $swb); $query_Planet1 = sprintf("SELECT * FROM planet WHERE ShipYard = %s AND PlayerName = %s", GetSQLValueString($tester, "int"), GetSQLValueString($colname_Planet1, "text")); $Planet1 = mysql_query($query_Planet1, $swb) or die(mysql_error()); $row_Planet1 = mysql_fetch_assoc($Planet1); $totalRows_Planet1 = mysql_num_rows($Planet1); ?> EDIT: sorry, didnt realise it was sorted. Quote Link to comment https://forums.phpfreaks.com/topic/235189-select-query-with-2-conditions/#findComment-1208641 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.