Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New Coder
    Join Date
    Jul 2005
    Posts
    63
    Thanks
    0
    Thanked 0 Times in 0 Posts

    haveing problem with code

    Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/sytodave/public_html/test/activate.php on line 15


    can some one help me

    PHP Code:
    <? 
    /* Account activation script */ 

    // Get database connection 
    include 'mysql_connect.php'

    // Create variables from URL. 

    $userid $_REQUEST['id']; 
    $code $_REQUEST['code']; 

    $sql mysql_query("UPDATE activation   SET activated='1' WHERE userid='$userid' AND password='$code'"); 

    $sql_doublecheck mysql_query("SELECT * FROM activation   WHERE userid='$userid' AND password='$code' AND activated='1'"); 
    $doublecheck mysql_num_rows($sql_doublecheck); 

    if(
    $doublecheck == 0){ 
        echo 
    "<strong><font color=red>Your account could not be activated!</font></strong>"
    } elseif (
    $doublecheck 0) { 
        echo 
    "<strong>Your account has been activated!</strong> You may login below!<br />"
        include 
    'login.php'


    ?>

  • #2
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,174
    Thanks
    19
    Thanked 66 Times in 65 Posts
    This wont fix it, but it will give you the sql error. Basically your sql query is bombing out
    PHP Code:
    <? 
    /* Account activation script */ 

    // Get database connection
    include 'mysql_connect.php'

    // Create variables from URL.

    $userid $_REQUEST['id']; 
    $code $_REQUEST['code']; 

    $sql mysql_query("UPDATE activation   SET activated='1' WHERE userid='$userid' AND password='$code'"); 

    $sql_doublecheck mysql_query("SELECT * FROM activation   WHERE userid='$userid' AND password='$code' AND activated='1'") or die(mysql_error()); 
    $doublecheck mysql_num_rows($sql_doublecheck); 

    if(
    $doublecheck == 0){ 
        echo 
    "<strong><font color=red>Your account could not be activated!</font></strong>"
    } elseif (
    $doublecheck 0) { 
        echo 
    "<strong>Your account has been activated!</strong> You may login below!<br />"
        include 
    'login.php'


    ?>

  • #3
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    I'd say you're getting the error from the big spaces you have here:
    PHP Code:
    UPDATE activation   SET activa 
    and
    PHP Code:
    SELECT FROM activation   WHERE use 
    Should only have 1 space after 'activation' not 3

  • #4
    Senior Coder
    Join Date
    Aug 2003
    Location
    One step ahead of you.
    Posts
    2,815
    Thanks
    0
    Thanked 3 Times in 3 Posts
    I don't think it's becouse of aditional whitespace chars. I don't see any errors in thwe querys. Both may have the same typo or something...
    I'm not sure if this was any help, but I hope it didn't make you stupider.

    Experience is something you get just after you really need it.
    PHP Installation Guide Feedback welcome.

  • #5
    Regular Coder
    Join Date
    Feb 2005
    Location
    UK
    Posts
    133
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Nightfire
    I'd say you're getting the error from the big spaces you have here:
    PHP Code:
    UPDATE activation   SET activa 
    and
    PHP Code:
    SELECT FROM activation   WHERE use 
    Should only have 1 space after 'activation' not 3
    SQL doesn't care about whitespace, as long as there's >1 space

  • #6
    Regular Coder
    Join Date
    Feb 2005
    Location
    UK
    Posts
    133
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I would say that your code in mysql_connect.php isn't connecting properly

  • #7
    New Coder
    Join Date
    Jul 2005
    Posts
    63
    Thanks
    0
    Thanked 0 Times in 0 Posts
    could it be the datbase is not set up rite

  • #8
    New to the CF scene
    Join Date
    Sep 2005
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Noodles24
    I would say that your code in mysql_connect.php isn't connecting properly
    I think you are right. Maybe a missing comma or something "small" like that

    Page


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •