r/PHPhelp • u/Destrudooo • Jan 10 '25
Solved Error in php code ...I'm beginner
Here is the code , and thanks in advance.
protected function setUser($uid,$pwd,$email){
$this->connect()->prepare('INSERT INTO users ( users_uid , users_pwd , users_email) VALUES ( ? , ? , ? ) ');$hashedPwd = password_hash($pwd, PASSWORD_DEFAULT);
if (!$stmt->execute(array($uid,$email,$hashedPwd)){
$stmt = null ; header("location: ../index.php?error=stmtfailed") ; exit();
} }
The Error
Parse error: syntax error, unexpected ';' in C:\Program Files\Ampps\www\projectxxx\classes\signup.classes.php on line 17
4
Upvotes
View all comments
Show parent comment
1
u/colshrapnel Jan 15 '25
Oh come on! It's not a rocket science. Citing myself:
mysqli bears one unique feature: all its functions can be accessed using both object and procedural syntax. Means each function can be called either as a function or as an object's method:
The only difference is that for the object syntax we take the function's parameter ($mysqli for example), add the object operator (->) and then call the actual method name, cutting off the redundant "mysqli" part.
There is nothing to learn. Just a bit shorter syntax.