0

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)) {

}
3
Contributors
6
Replies
7
Views
6 Years
Discussion Span
Last Post by diafol
0

its just a custom function

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

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(); ?>

Edited by rakwel10: n/a

0

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?

0

I solved it!!! haha

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

Thanks everyone for your comments : )

Edited by rakwel10: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.