-5

I am trying to insert some data in the database but it gives me a really confusing error

Now the error is: Parse error: syntax error, unexpected ')'

Code:

$query = mysql_query("INSERT INTO `members` VALUES (''," .$username ."," . $password . "," . $date . "," .$email . ",1'"));
  • 1
    You're missing a couple of concatenation operators (`.`). Also, [this](http://stackoverflow.com/questions/60174/how-to-prevent-sql-injection-in-php?rq=1). –  Jul 20 '13 at 19:03
  • I've removed my answer. Because there're so many errors. You should learn about basic PHP strings first. – Fallen Jul 20 '13 at 19:13

5 Answers5

0

You forgot some dots over there.

$query = mysql_query("INSERT INTO `members` VALUES (" .$username ."," . $password .  "," . $date . ","  .$email . ",1)");
Raz Harush
  • 739
  • 1
  • 6
  • 21
0

you have many mistakes , you forgot points . you forget ) .

you should also specify the columns names

this should work for you

$query = mysql_query("INSERT INTO `members` (firstcolumn ,username , password ,date,email , lastcolumn) VALUES ('' ,'$username','$password','$date','$email',1 )  ");
                                               ^----------^--------^-----^----^-----^^---your columns

HERE genaeral rule how to use insert :

INSERT into table (column1 , column2 , column3) VALUES (value1 , value2 , value3)
echo_Me
  • 37,078
  • 5
  • 58
  • 78
0

Try this (replace x,y,z,a,b with column name):

$query = mysql_query("INSERT INTO `members` (`x`,`y`,`z`,`a`,`b`) VALUES ('','.$username.','.$password.','.$date .','.$email.','1'"));

You haven't used ' and " in correct place.

Mohammad Mahdi Naderi
  • 2,975
  • 2
  • 14
  • 9
0

write your query and add at the end

or die(mysql_error());

what it says?

berzins92
  • 55
  • 8
0

I've worked it out now. No more answers