-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

12
  • Read about queries first. Commented Jun 9, 2015 at 7:58
  • 1
    I think INSERT INTO not use SET statement use VALUES() instead Commented Jun 9, 2015 at 7:59
  • 1
    You post 13 lines of code and an error message that refers to line 67. What are we looking for? Commented Jun 9, 2015 at 8:01
  • @Hobo Sapiens It is the snippet part of the code.. editing the OP now Commented Jun 9, 2015 at 8:01
  • @ChanomFirst I tried not using set either, however same error occurs. Commented Jun 9, 2015 at 8:06

2 Answers 2

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=?";
Sign up to request clarification or add additional context in comments.

2 Comments

The logic I am trying to use is basically the one being showed here. I can't understand which part I am missing :/
This is my code full: justpaste.it/phpsql
-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);

7 Comments

1. $Facebookid 2. $firstname 3. $lastname 4. $FBpictureURL 5. $Gender 6. $UserEmail Total of 6. isssss is 6. So this answer is irrelevant.
@LoganWayne Facebookid is integer and the rest are variables. (Gender is char). Am I missing something?
@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 - does your code from your post really comes from MySQLDao.php file?
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.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.