Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mysql Insert Into not inserting

Status
Not open for further replies.

Marine1969

IS-IT--Management
Mar 5, 2015
60
US
I am trying to insert a record into my table and although errors are turned on the code executes but there is no record inserted. I have tried a couple different iterations of code, below is the current. There are only 3 fields I am trying to insert as it is stripped down from 10 fields to these 3. I am beginning to believe that the issue may be with mysql.

PHP:
$str ="Insert Into clients (username, password, email)
                            Values (:username, :password, :email)";
                
        $uname=$_POST["uname"];
        $password = $_POST["pword"];
        $hash = password_hash($password, PASSWORD_DEFAULT);
        $email=$_POST["email"];
        
        $stmt = $conn->prepare($str); 	     
        $stmt->execute(array('username'=> $uname, 'password'=>$hash, 'email'=>$_POST["email"]));
 
Hi

Extremely interesting that your code works for me. I expected to fail because of unspecified parameters. Anyway, first I would try to fix the parameter names :
Code:
[navy]$stmt[/navy][teal]->[/teal][COLOR=orange]execute[/color][teal]([/teal][b]array[/b][teal]([/teal][i][green]'[highlight]:[/highlight]username'[/green][/i][teal]=>[/teal] [navy]$uname[/navy][teal],[/teal] [i][green]'[highlight]:[/highlight]password'[/green][/i][teal]=>[/teal][navy]$hash[/navy][teal],[/teal] [i][green]'[highlight]:[/highlight]email'[/green][/i][teal]=>[/teal][navy]$email[/navy][teal]));[/teal]

BTW, sure there is no transaction started before the code you quoted ?

Feherke.
feherke.github.io
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top