$UniqueID = rand(5400, 40000);
$InsertQuery = $c->prepare("INSERT INTO dbo.Users_Master (
UserUID, UserID, Pw, JoinDate, Admin, AdminLevel, UseQueue, Status, Leave, UserType, Point)
VALUES (:UserUID, :UserID, :Pw, :Date, :Admin, :AdminLevel, :UseQue, :Status, :Leave, :UserType, :Point)");
$Param = array ($UniqueID, $_POST['Username'], $_POST['Password'], '2013-21-10', 'False', '0', 'False', '0', '0', 'P', '0');
$InsertQuery->execute($Param);
Hello. My above code does have the correct column names/table name for my database, but my insert is not working? Can anyone see why?
I have went over this query like 10 times, trying to spot the mistake but I just cant try it. I have tried binding the params the traditional way:
$InsertQuery->bindParam(':UserUID', $UniqueID, PDO::PARAM_INT);
$InsertQuery->bindParam(':UserID', $_POST['Username'], PDO::PARAM_STR);
$InsertQuery->bindParam(':Pw', $_POST['Password'], PDO::PARAM_STR);
$InsertQuery->bindParam(':Date', '2013-21-10', PDO::PARAM_STR);
$InsertQuery->bindParam(':Admin', 'False', PDO::PARAM_STR);
$InsertQuery->bindParam(':AdminLevel', '0', PDO::PARAM_INT);
$InsertQuery->bindParam(':UseQue', '0', PDO::PARAM_INT);
$InsertQuery->bindParam(':Status', '0', PDO::PARAM_INT);
$InsertQuery->bindParam(':Leave', '0', PDO::PARAM_INT);
$InsertQuery->bindParam(':UserType', 'P', PDO::PARAM_STR);
$InsertQuery->bindParam(':Point', '0', PDO::PARAM_INT);
This proven no luck either.
“trying to spot the mistake” is extremely inefficient way to spot a mistake.
A programmer have to ask their program to do so.
IN case with PDO issues one have to tell PDO to raise an error on error:
have to be set right after connect, or even better – as a connect option.
it will retell you whatever error occurred in database – so, you will know, what’s going wrong.
There are also some issues with your code
so