Jump to content

Select query with 2 conditions


mrt003003

Recommended Posts

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 :|

Link to comment
https://forums.phpfreaks.com/topic/235189-select-query-with-2-conditions/
Share on other sites

<?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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.