Jump to content

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


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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.