Click to See Complete Forum and Search --> : [RESOLVED] error: undefined index?


dz_boy
08-16-2007, 02:50 PM
I get an undefined index on 'family_id' in this last line of this code. Any ideas as to why?

$sql3 = 'SELECT `family_id` FROM `Family` WHERE `family_name` = \''. $_POST['family_name'] .'\' and `f_pass` = \''. $f_pass .'\' LIMIT 1';
$result = @mysql_query($sql3);
$row = mysql_fetch_row($result);
$fam_id = $row['family_id'];

ellisgl
08-16-2007, 03:37 PM
$result = mysql_query($sql3) or die(mysql_error());

See what you get.


Also mysql_real_escape_string($_POST['family_name']) or mysql_escape_string (if you are using an older version of php)

waylon999
08-16-2007, 03:41 PM
try removing the single quotes around family_id in the select statement, and using mysql_fetch_assoc($result)

dz_boy
08-16-2007, 03:45 PM
removing the quotes did it. I didn't realize that made any difference, but thanks!

ellisgl
08-16-2007, 03:46 PM
Hmm.. Oh fricken magic quotes...