Jump to content

MYSQL_QUERY help please


lordphate

Recommended Posts

Okay, i know this works perectly well when just trying to select clb_id, but when adding asa_id and nat_id.

 

If you know what's wrong can you show how to fix, and WHY it needs to be that way, so i can learn from my mistakes? Thanks!

<?php

$query = "SELECT clb_id,asa_id,nat_id FROM flashchat_rooms WHERE id=".$rec['id'];
$result = mysql_query($query);
$result = @mysql_result($result,0);

IF( $result["clb_id"] == "0" && $result["asa_id"] == "0" && $result["nat_id"] == "0"){
	  $stmt = new Statement("SELECT * FROM {$GLOBALS['fc_config']['db']['pref']}rooms WHERE ispublic IS NOT NULL AND ispermanent IS NOT NULL ORDER BY ispermanent");
			if($rs = $stmt->process()) {
				while($rec = $rs->next()) {
					$this->addRoom($rec, $rooms, $room_pass);
				}
  				}
                 }
       elseif( $result["clb_id"] > "0" && $result["asa_id"] == "0" && $result["nat_id"] == "0") {
       $stmt = new Statement("SELECT * FROM {$GLOBALS['fc_config']['db']['pref']}rooms WHERE ispublic IS NULL AND ispermanent IS NOT NULL AND clb_id=". $result["clb_id"] ." ORDER BY created");
			if($rs = $stmt->process())
		  	{
				while($rec = $rs->next())
			  		{
						$this->addRoom($rec, $rooms, $room_pass);
				  	}
				}

                   }
       elseif( $result["clb_id"] == "0" && $result["asa_id"] > "0" && $result["nat_id"] == "0") {

       $stmt = new Statement("SELECT * FROM {$GLOBALS['fc_config']['db']['pref']}rooms WHERE ispublic IS NULL AND ispermanent IS NOT NULL AND asa_id=". $result["asa_id"] ." ORDER BY created");
			if($rs = $stmt->process())
		  	{
					while($rec = $rs->next())
			  		{
						$this->addRoom($rec, $rooms, $room_pass);
				  	}
				}

                   }
        elseif( $result["clb_id"] == "0" && $result["asa_id"] == "0" && $result["nat_id"] > "0") {
               $stmt = new Statement("SELECT * FROM {$GLOBALS['fc_config']['db']['pref']}rooms WHERE ispublic IS NULL AND ispermanent IS NOT NULL AND nat_id=". $result["nat_id"] ." ORDER BY created");
			if($rs = $stmt->process())
		  	{
					while($rec = $rs->next())
			  		{
						$this->addRoom($rec, $rooms, $room_pass);
				  	}
				}

                   } ?>

Link to comment
https://forums.phpfreaks.com/topic/54869-mysql_query-help-please/
Share on other sites

$result = @mysql_result($result,0);

 

$result = @mysql_result($result,*0*); Is selecting the first column which is clb_id (0)

 

You need to beable to select ($result,1,2); I dont code or havent used your style of retrieving info so im not to sure how to solve your problem..

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.