Page 1 of 1

MYSQL_ASSOC vs. MYSQL_NUM? i keep receiving an error

Posted: Mon Jun 12, 2006 6:03 pm
by danselstudios
CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are:

I get this error when i use "MYSQL_ASSOC"
when i use "MYSQL_NUM" i get my results that are expected.

heres the specific code i'm using:

Code: Select all

if( $db ){ 
	$user = trim($_POST['username']);
	$pass = trim($_POST['userpass']);
	$query = "SELECT userid, useranswer FROM authenticate_user WHERE username = '$user' AND userpass = '$pass'";
	$result = mysql_query($query);
	if( $result ){
		$row = mysql_fetch_array($result, MYSQL_NUM ); // IF I USE MYSQL_ASSOC...
		if( $row ){
			echo '<br />A complete Success!<br />';
			echo $row[0].'<br />'.$row[1];               // ...AND $row['userid'] & $row['useranswer'] I GET CGI Error
		}
		else{
			$errors2[] = 'Submitted info does not match.';
		}
	}
	else{
		$errors2[] = 'Could not retrieve information. Please try again.';
	}
	mysql_free_result($result);
}
else{
        $errors2[] = 'Could not connect to database.';
}
why doesn't it work?

Posted: Mon Jun 12, 2006 6:39 pm
by bdlang
I have no clue why that wouldn't work...maybe something in your code where you reference $row['index'] rather than $row[0]. What generates that error anyway? What version of PHP are you using? Is this under Dreamweaver or something similar?

Have you tried mysql_fetch_assoc()?

Posted: Mon Jun 12, 2006 7:00 pm
by danselstudios
you know i learned about mysql_fetch_assoc and mysql_fetch_num...I suppose this is faster, or at least it reduces the number of lines of code you use to execute the command.

anyway, i don't understand why it doesn't work either way.

Posted: Tue Jun 13, 2006 5:25 am
by dibyendrah
what is the error ? Please use

Code: Select all

mysql_query($sql) or mysql_error($conn);
And post the error. That will help to solve your problem.

Posted: Tue Jun 13, 2006 11:08 am
by danselstudios
Alright, i found the freaking error...the form's action was to a php file that doesn't exist instead of self.

thanks everyone!!!