-5

I am getting error:

Parse error: syntax error, unexpected ',', expecting '&' or variable (T_VARIABLE) in /root/folder/MySQLDao.php on line 67

However, everything seems fine. The chunk of code is:

public function registerUser($Facebookid, $firstname, $lastname, $FBpictureURL, $Gender, $UserEmail)
{
    $sql = "insert into Users set FacebookId=?, firstname=?, lastname=?, FBpictureURL=?, Gender=?, UserEmail=?";
    $statement = $this->conn->prepare($sql);  // Line 66
                                              // Line 67 is here
    if (!$statement)                          // Line 68
    throw new Exception($statement->error);

    $statement->bind_param("isssss", $Facebookid, $firstname, $lastname, $FBpictureURL, $Gender, $UserEmail);
    $returnValue = $statement->execute();

    return $returnValue;
}

Edit: I got lots of criticism about duplicate post, however, none of the answers solved my solution so far. I have of course checked StackOverflow before I post my question. Anyway, the ones still willing to help, I pasted my code in here: http://justpaste.it/phpsql

senty
  • 12,385
  • 28
  • 130
  • 260
  • Read about queries first. – Sougata Bose Jun 09 '15 at 07:58
  • 1
    I think INSERT INTO not use SET statement use VALUES() instead – Chanom First Jun 09 '15 at 07:59
  • 1
    You post 13 lines of code and an error message that refers to line 67. What are we looking for? –  Jun 09 '15 at 08:01
  • @Hobo Sapiens It is the snippet part of the code.. editing the OP now – senty Jun 09 '15 at 08:01
  • @ChanomFirst I tried not using set either, however same error occurs. – senty Jun 09 '15 at 08:06
  • The line you indicate as line 67 won't generate that error message. Are you looking at the right file? –  Jun 09 '15 at 08:09
  • your insert command is wrong, take a look here http://www.phpeveryday.com/articles/PDO-Insert-and-Update-Statement-Use-Prepared-Statement-P552.html – RST Jun 09 '15 at 08:11
  • your sql query is wrong learn about sql queries http://www.w3schools.com/sql/ – Syed mohamed aladeen Jun 09 '15 at 08:15
  • @syedmohamedumar I also used it in capital as if: `$sql = "INSERT INTO Users FacebookId=?, firstname=?, lastname=?, FBpictureURL=?, Gender=?, UserEmail=?";` – senty Jun 09 '15 at 08:18
  • @syedmohamedumar Also, using parenthesis `$sql = "insert into Users (FacebookId=?, firstname=?, lastname=?, FBpictureURL=?, Gender=?, UserEmail=?)";` not working either. – senty Jun 09 '15 at 08:20
  • @senty `"INSERT INTO Users (FacebookId, firstname, lastname, FBpictureURL, Gender, UserEmail) VALUES (?,?,?,?,?,?)"` – Logan Wayne Jun 09 '15 at 08:23
  • @LoganWayne I am going to get the question marks from POST. Am I making some logic mistakes? – senty Jun 09 '15 at 08:25

2 Answers2

0

Note:

  • Make sure that your given code is in MySQLDao.php file. Because it is hard to believe that it will return such error for that line (67), which is just blank.
  • Your insert query setup looks okay if your extension supports MySQL

It would look like this in standard form:

$sql = "INSERT INTO Users (FacebookId, firstname, lastname, FBpictureURL, Gender, UserEmail) 
        VALUES (?,?,?,?,?,?)";
  • Did you call the function correctly? Make sure that the passed-on variables for your registerUser() function is correctly passed-on from your POST form.

You may call your function like this (this is just an example way to call the function):

registerUser($_POST["Facebookid"],$_POST["firstname"],$_POST["lastname"],$_POST["FBPictureURL"],$_POST["Gender"],$_POST["UserEmail"]);
  • If the code in your given link is your updated copy, you forgot "SET" in your query.

It should look like this:

"INSERT INTO Users SET FacebookId=?, firstname=?, lastname=?, FBpictureURL=?, Gender=?, UserEmail=?";
Logan Wayne
  • 6,001
  • 16
  • 31
  • 49
  • The logic I am trying to use is basically [the one being showed here](http://swiftdeveloperblog.com/store-user-information-in-mysql-database/). I can't understand which part I am missing :/ – senty Jun 09 '15 at 08:37
  • This is my code full: http://justpaste.it/phpsql – senty Jun 09 '15 at 08:42
-1

in your sql statement there is 6 columns and in your bind_param function you are providing 7 params if there is no need of "issss" then please remove it because i thing it is id and if you have settle it as primary key and auto increment then you don't need to provide this argument expected code:

$statement->bind_param($Facebookid, $firstname, $lastname, $FBpictureURL, $Gender, $UserEmail);
kevin
  • 300
  • 2
  • 11
  • 1. `$Facebookid` 2. `$firstname` 3. `$lastname` 4. `$FBpictureURL` 5. `$Gender` 6. `$UserEmail` Total of 6. `isssss` is 6. So this answer is irrelevant. – Logan Wayne Jun 09 '15 at 08:14
  • @LoganWayne Facebookid is integer and the rest are variables. (Gender is char). Am I missing something? – senty Jun 09 '15 at 08:17
  • @LoganWayne I am actually running `register.php ` and it `require` the MySQLDao.php. The error I am getting shows in `domain.com/register.php`; but the error is as it is in original post. – senty Jun 09 '15 at 08:24
  • @senty - does your code from your post really comes from `MySQLDao.php` file? – Logan Wayne Jun 09 '15 at 08:40
  • No, I am trying to send the data from iPhone app [Swift (iOS)] but now, I am just opened www.domain.com/register.php without posting anything. – senty Jun 09 '15 at 08:46
  • @senty - what are you currently getting? – Logan Wayne Jun 09 '15 at 08:58
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/80028/discussion-between-logan-wayne-and-senty). – Logan Wayne Jun 09 '15 at 09:11