Posting values to a table

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
mikes1471
Forum Commoner
Posts: 88
Joined: Sat Jan 24, 2009 3:29 pm

Posting values to a table

Post by mikes1471 »

Hi Everyone, I have a working registration form but recently added 10 new fields to the table it posts to, consequently, what did look like this:

Code: Select all

$sql4 = "INSERT INTO `users`
                    (`firstname`,`lastname`,`yob`,`mob`,`dob`,`email`,`username`,`password`,`gender`,`sexuality`,`city`,`postcode`,`country`,`date`)
                    VALUES ('".$firstname."','".$lastname."','".$yob."','".$mob."','".$dob."','".$email."','".$username."','".md5($password)."','".$gender."','".$sexuality."','".$city."','".$postcode."','".$country."','".$date."')";
            $res4 = mysql_query($sql4) or die(mysql_error());
            echo "Hello <b>".$username."</b> you have been registered!<b><br>Please wait while you are re-directed";
I have changed to look like this:

Code: Select all

$sql4 = "INSERT INTO `users`
 
(`firstname`,`lastname`,`yob`,`mob`,`dob`,`email`,`username`,`password`,`gender`,`sexuality`,`city`,`postcode`,`country`,`date`,`userid`,`albumid`,`type`,`name`,`description`,`defaultimage`,`currentrate`,`imagedescription`,`count`,`cover`) 
                   VALUES ('".$firstname."','".$lastname."','".$yob."','".$mob."','".$dob."','".$email."','".$username."','".md5($password)."','".$gender."','".$sexuality."','".$city."','".$postcode."','".$country."','".$date.",' ',' ',' ',' ',' ','0','0',' ','0','"images/nocover.jpg"')";
            $res4 = mysql_query($sql4) or die(mysql_error());
            echo "Hello <b>".$username."</b> you have been registered!<b><br>Please wait while you are re-directed";
I refer to this part of my code as the error I get says "Parse error: syntax error, unexpected T_STRING in /var/www/vhosts/picfrisky.com/httpdocs/regform/register.php on line 260"

and Im not sure where Ive gone wrong, could someone advise me please?
User avatar
Robert07
Forum Contributor
Posts: 113
Joined: Tue Jun 17, 2008 1:41 pm

Re: Posting values to a table

Post by Robert07 »

Did you mean to insert spaces into most of the new fields or were they supposed to be empty?
mikes1471
Forum Commoner
Posts: 88
Joined: Sat Jan 24, 2009 3:29 pm

Re: Posting values to a table

Post by mikes1471 »

Yes those are empty results
Arsench2000
Forum Commoner
Posts: 38
Joined: Sat Sep 15, 2007 8:18 pm

Re: Posting values to a table

Post by Arsench2000 »

mikes1471 wrote:Yes those are empty results
I think the insert statement not correct I have a insert from fields or other variables and doing like this

insert into table VALUES (' ', '$name', 'l_name') etc... if there are rows or columns that will not be inserted you have to leave it blanc like (' ' , '$name' in this case the first ( ' ' ) is a blanc because it is for a ID that is autoincrement and dnt need to be inserted. You dont need to insert like ' " . $variable . " ' I think it is not correctly.

regards and sorry if my response didnt help you.
Post Reply