Jump to content

doing something like if( $sql->query('') {..


play_

Recommended Posts

I haev an SQL class.

Here's what the query method looks like:

 

function query($query) {
	$this->result = @ mysql_query($query, $this->linkid);
	if(!$this->result) {
		echo "--[ query failed ]--";	exit();
	}
}

 

 

Now, I am doing something like this on another page:

$sql = new SQL();

$query = "query here";
if( $sql->query($query) ) {
header("Location: " . $_SERVER['PHP_SELF'] . "?result=success");
} else {
echo 'problem';
}

 

 

The problem with the above is that the query is indeed being ran (i checked in the database), but the page is not redirecting

But the following works (it redirects):

 

$query = 'some query here';
$sql->query($query);
header("Location: " . $_SERVER['PHP_SELF'] . "?result=success");

 

In other words, if i take out the if statement, it works as intended. why?

Link to comment
https://forums.phpfreaks.com/topic/90306-doing-something-like-if-sql-query/
Share on other sites

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.