Im checked my sql, its working fine.
But im still getting this error:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in..

$sql = "SELECT date FROM tbl_tour_profile";
	$result = mysql_query($sql);
	confirm_query($result); // this is the die function of sql
	

	$i=0;
	while($date_set = mysql_fetch_array($result)) {

}

what is confirm_query() function can you write its code

its just a custom function

function confirm_query($result_set) {
		if (!$result_set) {
			die("Database query failed: " . mysql_error());
		}

the whole code is this:

<? ob_start(); ?>
<?php require_once("../includes/session.php");?>
<?php require_once("../includes/connection.php");?>
<?php require_once("../includes/functions.php");?>
<?php confirm_logged_in_admin(); ?>
<?php confirm_if_admin(); ?>
<?php

date_default_timezone_set('Asia/Manila');
		$dt = gmdate('U');
		$mysql_datetime = strftime("%Y-%m-%d %H:%M:%S", $dt);
		$compare_date = strftime("%Y-%m-%d", $dt);
		echo $mysql_datetime;
		echo "<br>";
		echo $compare_date;
		
		
	$sql = "SELECT date FROM tbl_tour_profile";
	$result = mysql_query($sql);
	confirm_query($result);
	

	$i=0;
	while($date_set = mysql_fetch_array($result)) {
		$d[$i] = $date_set['date'];

		if ($d[$i] <= $compare_date){
			//else the tour is not in the current date
			$unix_timestamp = strtotime("-6 months ");
			$six_months_less = strftime("%Y-%m-%d %H:%M:%S", $unix_timestamp);

				
				if ($d[$i] <= $six_months_less) {
					//if the tour is morethan 6months old, go to tbl_tour_past
					
					$update = "UPDATE tbl_tour_profile 
					SET tourStat = 'past' WHERE date = '$d[$i]'";
					
					$result = mysql_query($update);
					confirm_query($result);
					
					if ($result){$message = "updated past"; alert_msg($message);}
						else{$message = "sorry not updated past"; alert_msg($message);}						
						
				}else{
					//if the tour is wihin 6months, go to tbl_tour_recent
					
					$update = "UPDATE tbl_tour_profile 
					SET tourStat = 'recent' WHERE date = '$d[$i]'";
					
					$result = mysql_query($update);
					confirm_query($result);
					
					if ($result){$message = "updated recent"; alert_msg($message);}
						else{$message = "sorry not updated recent"; alert_msg($message);}	
				}			
		}
		else{
			//the tour is up to date
					$update = "UPDATE tbl_tour_profile 
					SET tourStat = 'current' WHERE date = '$d[$i]'";
					
					$result = mysql_query($update);
					confirm_query($result);
					
					if ($result){$message = "updated current"; alert_msg($message);}
						else{$message = "sorry not updated current"; alert_msg($message);}					
		}
		$i++;
	}
		
//redirect_to("../admin_tour.php");	
		
		
?>

<? ob_flush(); ?>
Member Avatar for diafol

The confirm function code works for me. So that's OK.

SELECT date FROM tbl_tour_profile

Check that the field 'date' is correct and the name of the table.

Are you sure that the error is for this query and not for one of the others?

I solved it!!! haha

the error is I put 2 sql statements in 1 variable w/c is "$result".

Thanks everyone for your comments : )

Member Avatar for diafol

You did> What was the problem?

Mark as solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.