mysql_affected_rows error

    Date: 11/22/06 (PHP Community)    Keywords: mysql, database, sql

    ETA: Solved with the help of '[info]'nickinuse.

    Hi guys, I'm trying to make an email verification script.
    1. User enters values to the contact form (done)
    2. Contact form sends verification email to the entered user email (done)
    3. User clicks on the link and verification process is complete (I'm stuck here)



    // 1. open connection to MySQL (okay, done!)
    $koneksi = mysql_connect($db_host, $db_user, $db_password) or die(mysql_error());
    $db_select = mysql_select_db($db_name) or die(mysql_error());

    // 2. query the database to see if the verification string match the ones in the database (this is okay, too!)
    $query = "SELECT email_id FROM email_ver WHERE verify_string=$verify";
    $result = mysql_query($query);
    while ( $data = mysql_fetch_array($result) )
    { $drid = $data['email_id']; }
    if ($drid!=$id)
    { $t="There are no such ID or request."; }
    else {
    // 3. query the database to update that email has been verified (this is where I'm stuck!)
    $query = "UPDATE email_ver SET email_verify='y', verify_string='0' WHERE email_id=$id";
    // specifically these next two lines!
    $result = mysql_query($query) or die(mysql_error());
    $num_rows = mysql_affected_rows($result);
    // if the query work
    if ($num_rows > 0) { echo "Yay! Your email is valid!"; }
    }


    I got this following error:
    Warning: mysql_affected_rows(): supplied argument is not a valid MySQL-Link resource

    Why is that happen? When the actual query is successfully done in the database (I've checked and re-checked). [Edit: It's because I'm feeding it with the wrong kind of resource. *LOL*]

    Thanks!

    Source: http://community.livejournal.com/php/513516.html

« include paths... || New to PEAR »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home