1

Please How can i use prepared statement to update one table and insert into another table. i did what i no was right but the when i submit the form on that page, it just give me a blank page and nothing happened in the two database see what it look like

$check = "INSERT INTO users(userEmail, password, joinDate, recEmails,
                            isActive, hash, lastUpdated) 
            VALUES (?, ?, NOW(), 1, 0, ?, NOW() ) ";

$stmt = $mysqli->prepare($check);
$stmt->bind_param('sss',$emailAddy,$password,$hash );

$stmt->execute();
$stmt->close();

$check1="UPDATE pin SET status = '1', usedby = ?,WHERE pin = ?";

$stmt = $mysqli->prepare($check1);

$stmt->bind_param('ss',$emailAddy,$pin);                
$stmt->execute();
$stmt->close();

The result i get is this example.com is currently unable to handle this request. I have tried and discovered that the issue is hidden somewhere here, if i remove the update table instruction the code works fine but one i return the issue comes back. Please can anybody help?

RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
Oba
  • 11
  • 1
  • Where do you set the values to `$emailAddy`, `$password`, `$hash`, `$emailAddy` and `$pin`? – Alon Eitan Jan 21 '17 at 15:59
  • Why is your code always so oddly formatted, you can have more than one thing on a line you know. And indentation, indicted subordination, this is fall through code and should all start with the same indent – RiggsFolly Jan 21 '17 at 16:01
  • i declared them in functions and called for it in the signup page – Oba Jan 21 '17 at 16:02
  • sorry about that RiggsFolly – Oba Jan 21 '17 at 16:02
  • Please reformat your questions instead of asking a duplicate question. I've flagged your original question for deletion since this one's gotten an answer. – AmericanUmlaut Jan 21 '17 at 16:05

1 Answers1

2

You have an error here:

$check1 = "UPDATE pin SET status = '1', usedby = ?, WHERE pin = ?";

Change it to (Remove the , after usedby = ?)

$check1 = "UPDATE pin SET status = '1', usedby = ? WHERE pin = ?";
Alon Eitan
  • 11,997
  • 8
  • 49
  • 58