0

hi i have a script created for me and im attempting to add user_id so it it gets the userid from the users table so far i have done

CREATE TABLE IF NOT EXISTS `checkbox` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(50) NOT NULL,
  `male` varchar(10) COLLATE utf8_unicode_ci NOT NULL,
  `female` varchar(10) COLLATE utf8_unicode_ci NOT NULL,
  `couple` varchar(10) COLLATE utf8_unicode_ci NOT NULL,
  `tvtscd` varchar(10) COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=38 ;

and the sql string for it is

$query="INSERT INTO `checkbox`(`id`,`user_id`, `male`, `female`, `couple`, `tvtscd`) 
                         VALUES (NULL,'$Male', '$female','$Couple','$tvt' WHERE user_id = '".$_SESSION['userid']."' ")" or die(mysqli_error($MySQLi_CON));//ERROR LINE
                         $rs=mysql_query($MySQLi_CON,$query);
                         if(!$rs){
                         echo "adsada";
                         }

and i get a error as follows
Parse error: syntax error, unexpected ')' in /home/public_html/deleteaccount/home.php on line 528

i know its a "(" error but no matter which one i remove i still get a error in dreamweaver

what is best way around this

Edited by pritaeas: Moved to web dev.

4
Contributors
4
Replies
25
Views
1 Year
Discussion Span
Last Post by diafol
0

I think your problem is in the part

VALUES (NULL,'$Male', '$female','$Couple','$tvt' WHERE

Try changing it to

VALUES (NULL,'$Male', '$female','$Couple','$tvt') WHERE
0

hi i have a script created for me and im attempting to add user_id so it it gets the userid from the users table so far i have done

So just add the $user_id in the VALUES list IN THE RIGHT ORDER. Your SQL was placing it in a WHERE clause, instead of placing it as the second parameter in the VALUES list.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.