Jump to content

[SOLVED] Multiple WHERE statements


Clinton

Recommended Posts

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 'Terminated = '0' ORDER BY Position' at line 1

 

<?

// connect to database
include("inc/connect.php");

// include auth and nav
include("inc/auth.php");
include("inc/nav.php");

?>

<?
$rn=("SELECT * FROM users WHERE
username='" . $_SESSION['username']."'");

$rz=mysql_query($rn);

while($row=mysql_fetch_array($rz))
{
if($row["Status"]=="0"){
echo ("<br>Have a great day! <a href='logout.php'>Close</a>");
}else{
?>

<center><h3>Explosive Personnel</h3></center>

<?
$q1=mysql_query("SELECT * FROM roster WHERE Position <= '4' AND Terminated = '0' ORDER BY Position") or die(mysql_error());
$q1rz=mysql_query($q1);

while($row1 = mysql_fetch_array($q1rz)){
?>


<b><font color="orange" size="3"><? echo $row1['Name']; ?></font></b><br>
<i><? echo $row1['Title']; ?></i><br>
Cell: <? echo $row1['CellPhone']; ?> &nbsp &nbsp &nbsp Home: <? echo $row1['HomePhone']; ?><br>
E-Mail: <a href=mailto:<? echo $row1['Email']; ?>><? echo $row1['Email']; ?></a><br>
<? echo $row1['Notes']; ?><p>


<?
}
?>

</body>


</html>

<?
}}
?>

$q1rz = mysql_query("SELECT * FROM roster WHERE Position=<'4' and Terminated='0' ORDER BY Position ") or die(mysql_error());

 

I replaced the and in lowercase in hope that the other chages I've made have made it need the and now :P

 

I really help WHEREs now >.<

Interesting. I never thought about doing that but when I do I get an 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 'Terminated=0 ORDER BY Position DESC' at line 1

 

But if I do it the other way, Position, it works just fine. And yes, i'm not a complete idiot. ;-) LoL THe columns do exist. I've checked and rechecked my PHPAdmin and everything looks good.

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.