Jump to content

Test if query is successful


dzedward

Recommended Posts

do u want this?

$id = '5';
$sql2 = "SELECT advURL FROM adv WHERE ID = '$id'";
$qry2 = mysql_query($sql2)
or die("Query failed: " . mysql_error() . " Actual query: " . $sql);

$row = mysql_fetch_array($qry2);
if($row['advURL'] == ''){
echo "advURL is empty!!";
}

$sql = "SELECT ID FROM adv WHERE req = '$incoming'";

$qry = mysql_query($sql)
or die("Query failed: " . mysql_error() . " Actual query: " . $sql);

while($rand = mysql_fetch_object($qry)) {
        $request = $rand->ID;
        $id = $request+1;		

	$sql2 = "SELECT advURL FROM adv WHERE ID = '$id'";

   		$qry2 = mysql_query($sql2)
	or die("Query failed: " . mysql_error() . " Actual query: " . $sql2);
	if($qry2['advURL'] == ''){
		finish();
	} else {
		while($theId = mysql_fetch_object($qry2)) {
				$url = $theId->advURL;
			$newURL = $url;
				giveNew($newURL); 			
		}
	}     
}

function giveNew($next){
echo $next;
}
function finish(){
echo "Finish Line";
}

isnt $qry2['advURL']  undifined? i think you u need a fetch array on $qry2

		$qry2 = mysql_query($sql2)
	or die("Query failed: " . mysql_error() . " Actual query: " . $sql2);
	if($qry2['advURL'] == ''){
		finish();
	} else {

 

replace with this

		
                         $qry2 = mysql_query($sql2)
                         $row2 = mysql_fetch_array($qry2);
	or die("Query failed: " . mysql_error() . " Actual query: " . $sql2);
	if($row2['advURL'] == ''){
		finish();
	} else {

ooops forgot about the or die. use this


                         $qry2 = mysql_query($sql2) or die("Query failed: " . mysql_error() . " Actual query: " . $sql2);
                         $row2 = mysql_fetch_array($qry2);
	if($row2['advURL'] == ''){
		finish();
	} else {

ooops forgot about the or die. use this


                         $qry2 = mysql_query($sql2) or die("Query failed: " . mysql_error() . " Actual query: " . $sql2);
                         $row2 = mysql_fetch_array($qry2);
	if($row2['advURL'] == ''){
		finish();
	} else {

 

Using this I get no error, and I works if it is the last one in line.  But all others fail to move on to next url, just get blank.

this is the best i can do with out knowing exaclty what all these fields are

                      $qry2 = mysql_query($sql2) or die("Query failed: " . mysql_error() . " Actual query: " . $sql2);
                         $row2 = mysql_fetch_array($qry2);
	if($row2['advURL'] == ''){
		finish();
	} else {		
				$url = $row2['advURL'];
			$newURL = $url;
				giveNew($newURL); 			
		}
	}     
}

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.