sign up problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
m2babaey
Forum Contributor
Posts: 364
Joined: Sun May 20, 2007 9:26 am

sign up problem

Post by m2babaey »

Hi
this error:
Column count doesn't match value count at row 1
why happens?
the code is:

Code: Select all

$result=mysql_query("SELECT * FROM `publisher` WHERE `email`='$email'" )or die(mysql_error());
$count_row = mysql_num_rows($result);
if($count_row > 0)
{
    error("The email address you have provided already exists");
} 
$result=mysql_query("SELECT * FROM `publisher` WHERE `username`='$username'" )or die(mysql_error());
$count_row = mysql_num_rows($result);
if($count_row > 0)
{
    error("The username already exists. Please choose another one.");
}
else{ 
$signup=mysql_query("INSERT INTO `publisher` (fname ,lname ,email ,country ,company ,companyplace ,industry ,addr1 ,addr2
,city ,state ,zip ,phone , fax ,site ,sitelang ,sitetype ,traffic, trafficsource, tax, taxid, payee ,username, hear, newsletter, pass) VALUES
 (  '$fname' , '$lname' , '$email' , '$country' ,'$company' ,'$companyplace' ,'$industry' ,'$addr1', '$addr2'
'$city' ,'$state' ,'$zip' ,'$phone' ,'$fax' ,'$site' ,'$sitelang' ,'$sitetype' ,'$traffic' ,'$trafficsource','$tax','$taxid'
,'$payee' ,'$username','$hear','$newsletter','$pass' )") or die(mysql_error());
if($signup) echo "Thank you\n\nYou have registered successfully.";
$subject="Your Password";
$message=" Thank you for registering with us. Your login details is : \n\n username: $username \n\n password: $pass";
$sender="";
mail($email, $subject, $message ,$sender);


echo "Your password has been sent to your email.";
}
thanks in advance
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Count your columns specified then count the values specified to fill those columns. One or more will not match.
m2babaey
Forum Contributor
Posts: 364
Joined: Sun May 20, 2007 9:26 am

Post by m2babaey »

i counted 3 times. both of them were 26
maybe i need to count again :?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Code: Select all

<?php

$a=explode('VALUES','(fname ,lname ,email ,country ,company ,companyplace ,industry ,addr1 ,addr2
,city ,state ,zip ,phone , fax ,site ,sitelang ,sitetype ,traffic, trafficsource, tax, taxid, payee ,username, hear, newsletter, pass) VALUES
 (  \'$fname\' , \'$lname\' , \'$email\' , \'$country\' ,\'$company\' ,\'$companyplace\' ,\'$industry\' ,\'$addr1\', \'$addr2\'
\'$city\' ,\'$state\' ,\'$zip\' ,\'$phone\' ,\'$fax\' ,\'$site\' ,\'$sitelang\' ,\'$sitetype\' ,\'$traffic\' ,\'$trafficsource\',\'$tax\',\'$taxid\'
,\'$payee\' ,\'$username\',\'$hear\',\'$newsletter\',\'$pass\' )');
foreach($a as $k => $v){
 $a[$k] = array_map('trim',explode(',',trim($v,' ()')));
}
print_r($a);

Code: Select all

feyd:~ feyd$ php -f test.php 
Array
(
    [0] => Array
        (
            [0] => fname
            [1] => lname
            [2] => email
            [3] => country
            [4] => company
            [5] => companyplace
            [6] => industry
            [7] => addr1
            [8] => addr2
            [9] => city
            [10] => state
            [11] => zip
            [12] => phone
            [13] => fax
            [14] => site
            [15] => sitelang
            [16] => sitetype
            [17] => traffic
            [18] => trafficsource
            [19] => tax
            [20] => taxid
            [21] => payee
            [22] => username
            [23] => hear
            [24] => newsletter
            [25] => pass
        )

    [1] => Array
        (
            [0] => (  '$fname'
            [1] => '$lname'
            [2] => '$email'
            [3] => '$country'
            [4] => '$company'
            [5] => '$companyplace'
            [6] => '$industry'
            [7] => '$addr1'
            [8] => '$addr2'
'$city'
            [9] => '$state'
            [10] => '$zip'
            [11] => '$phone'
            [12] => '$fax'
            [13] => '$site'
            [14] => '$sitelang'
            [15] => '$sitetype'
            [16] => '$traffic'
            [17] => '$trafficsource'
            [18] => '$tax'
            [19] => '$taxid'
            [20] => '$payee'
            [21] => '$username'
            [22] => '$hear'
            [23] => '$newsletter'
            [24] => '$pass'
        )

)
Notice anything off?
m2babaey
Forum Contributor
Posts: 364
Joined: Sun May 20, 2007 9:26 am

Post by m2babaey »

thanks
i was missing a "," before city in the values
Post Reply