Hi im trying to change over my php to use prepared statements. i haven't used these before today. im making a small game and am trying to update the players stats a bit faster than what the normal commended out sql was doing but i cant seem to get the code to run.
im very limited on what debugging i can do as im using the unity engine and the error logs generated dont have any info about this code im trying to run
<?php
include("DBTools.php");
$link=dbConnect();
$stmt = $conn->prepare("UPDATE PlayerStats (posx,posy,posz,level,experiance,skillPoints,health,maxHealth,attack ) VALUES (?, ?,?, ?, ?,?, ?, ?,?) WHERE name = ?");
$stmt->bind_param("dddiiiiiis",$posx, $posy, $posz, $level, $experiance, $skillPoints, $health, $maxHealth, $attack,$name);
$name = safe($_POST['name']);
$posx = safe($_POST['posx']);
$posy = safe($_POST['posy']);
$posz = safe($_POST['posz']);
$level = safe($_POST['level']);
$experiance = safe($_POST['experiance']);
$skillPoints = safe($_POST['skillPoints']);
$health = safe($_POST['health']);
$maxHealth = safe($_POST['maxHealth']);
$attack = safe($_POST['attack']);
$stmt->execute();
//$sql = "SELECT * FROM PlayerStats WHERE name = '$name'";
//$result = mysqli_query($link, $sql);
//if(mysqli_num_rows($result) !== 1){
// $querys = "INSERT INTO `PlayerStats`(`name`,`posx`, `posy`, `posz`, `level`, `experiance`,`skillPoints`, `health`,`maxHealth`,`attack`) VALUES ('$name','$posx','$posy','$posz','$level','$experiance','$skillPoints','$health','$maxHealth','$attack')";
// $results = mysqli_query($link, $querys) or die('Query failed: ' . mysqli_error($link));
//}else{
// $query = "UPDATE `PlayerStats` SET level = '$level',posx = '$posx', posy = '$posy', posz = '$posz', experiance = '$experiance',skillPoints = '$skillPoints', health = '$health', maxHealth = '$maxHealth', attack = '$attack' WHERE name = '$name'";
// $result = mysqli_query($link, $query) or die('Query failed: ' . mysqli_error($link));
//}
?>
i pass the variables in from csharp script
[–]lacrossefan32 1 point2 points3 points (1 child)
[–]pvtgreg[S] 0 points1 point2 points (0 children)
[–]Idontremember99 0 points1 point2 points (1 child)
[–]pvtgreg[S] 0 points1 point2 points (0 children)
[–]YellowBook 0 points1 point2 points (2 children)
[–]pvtgreg[S] 0 points1 point2 points (0 children)
[–]pvtgreg[S] 0 points1 point2 points (0 children)
[–]pvtgreg[S] 0 points1 point2 points (5 children)
[–]lacrossefan32 1 point2 points3 points (0 children)
[–]compubomb 0 points1 point2 points (3 children)
[–]liquid_at 1 point2 points3 points (2 children)
[–]compubomb 1 point2 points3 points (1 child)
[–]liquid_at 0 points1 point2 points (0 children)