0

I have a error in my newsletter and I don't know what doing wrong. Please help me. Now I doing newsletter, first time I used MySQL in my code.

Here is the error:

Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 3 in subscribe.php on line 54

Here is my code:

    if($mail == NULL){

    }
    else{
        $token = sha1(time());
        $result1 = @mysql_query("INSERT INTO newsletter (Address,Token) VALUES (\"".$mail."\", \"".$token."\") ");
        if ($result1) {
            sendmail($mail);
        }
        else{ /*This else */
            $result2 = mysql_query("SELECT Confirmed FROM newsletter where Address = \"".$mail."\" ");
            $confirm = mysql_result($result2,0);
            if($confirm == "y"){
            }
            else if($confirm == "n"){
            }
        }
    }
    ?>

What I do wrong?

Kacper
  • 1
  • 1

1 Answers1

0

You could try:

(...)
else{ /*This else */
    $result2 = mysql_query("SELECT Confirmed FROM newsletter where Address = \"".$mail."\" ");
    if($row = mysql_fetch_array($result2)) {
        $confirm = $row["Confirmed"];
    }
    else {
        $confirm = "n"; // Returned 0 rows
    }
    $confirm = mysql_result($result2,0);
    if($confirm == "y"){
}
else if($confirm == "n"){
(...)
lpg
  • 4,897
  • 1
  • 16
  • 16