SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Apr 2013
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy Column count doesn't match value count at row 1

    Hello,

    I am new at programming and trying to make website with registration and login.
    So far I am stuck at when trying to executa registration script, can anyone please help me with this error? I would really appreciate any help with this as I am really stuck and confused about whats gone wrong...

    Code SQL:
    CREATE TABLE `users` (  
      `id` INT(11) NOT NULL AUTO_INCREMENT,  
      `username` VARCHAR(50) NOT NULL DEFAULT '',  
      `password` VARCHAR(128) NOT NULL DEFAULT '',  
      `email` VARCHAR(250) NOT NULL DEFAULT '',  
      `active` BINARY(1) NOT NULL DEFAULT '0',  
      PRIMARY KEY  (`id`)  
    ) ENGINE=MyISAM AUTO_INCREMENT=27 DEFAULT CHARSET=utf8;  
     
     
     
    CREATE TABLE `confirm` (  
      `id` INT(11) NOT NULL AUTO_INCREMENT,  
      `userid` VARCHAR(128) NOT NULL DEFAULT '',  
      `key` VARCHAR(128) NOT NULL DEFAULT '',  
      `email` VARCHAR(250) DEFAULT NULL,  
      PRIMARY KEY  (`id`)  
    ) ENGINE=MyISAM AUTO_INCREMENT=27 DEFAULT CHARSET=utf8;



    The script is..


    PHP Code:
    <?php

    include_once 'inc/php/config.php';
    include_once 
    'inc/php/functions.php';

    //setup some variables/arrays
    $action = array();
    $action['result'] = null;

    $text = array();

    //check if the form has been submitted
    if(isset($_POST['signup'])){

        
    //cleanup the variables
        //prevent mysql injection
        
    $username mysql_real_escape_string($_POST['username']);
        
    $password mysql_real_escape_string($_POST['password']);
        
    $email mysql_real_escape_string($_POST['email']);
        
        
    //quick/simple validation
        
    if(empty($username)){ $action['result'] = 'error'array_push($text,'You forgot your username'); }
        if(empty(
    $password)){ $action['result'] = 'error'array_push($text,'You forgot your password'); }
        if(empty(
    $email)){ $action['result'] = 'error'array_push($text,'You forgot your email'); }
        
        if(
    $action['result'] != 'error'){
                    
            
    $password md5($password);    
                
            
    //add to the database
            
    $add mysql_query("INSERT INTO `users` VALUES(NULL,'$username','$password','$email',0)");
            
            if(
    $add){
                
                
    //get the new user id
                
    $userid mysql_insert_id();
                
                
    //create a random key
                
    $key $username $email date('mY');
                
    $key md5($key);
                
                
    //add confirm row
                
    $confirm mysql_query("INSERT INTO `confirm` VALUES(NULL,'$userid','$key','$email')");    
                
                if(
    $confirm){
                
                    
    //include the swift class
                    
    include_once 'inc/php/swift/swift_required.php';
                
                    
    //put info into an array to send to the function
                    
    $info = array(
                        
    'username' => $username,
                        
    'email' => $email,
                        
    'key' => $key);
                
                    
    //send the email
                    
    if(send_email($info)){
                                    
                        
    //email sent
                        
    $action['result'] = 'success';
                        
    array_push($text,'Thanks for signing up. Please check your email for confirmation!');
                    
                    }else{
                        
                        
    $action['result'] = 'error';
                        
    array_push($text,'Could not send confirm email');
                    
                    }
                
                }else{
                    
                    
    $action['result'] = 'error';
                    
    array_push($text,'Confirm row was not added to the database. Reason: ' mysql_error());
                    
                }
                
            }else{
            
                
    $action['result'] = 'error';
                
    array_push($text,'User could not be added to the database. Reason: ' mysql_error());
            
            }
        
        }
        
        
    $action['text'] = $text;

    }

    ?>

    <?php
    include 'inc/elements/header.php'?>

    <?= show_errors($action); ?>

    <form method="post" action="">

        <fieldset>
        
            <ul>
                <li>
                    <label for="username">Username:
    Last edited by SpacePhoenix; Apr 6, 2013 at 01:01. Reason: placed php tags around php code

  2. #2
    SitePoint Member
    Join Date
    Mar 2013
    Posts
    16
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Where do you making the count?
    I dont see any count
    Please put the exact lines where you are trying to make the match


Bookmarks

Posting Permissions

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