i have this function:
function myFunction(string $name) {
    $db = mysql_connect("localhost", "root", "");
    mysql_select_db(...); 
    $insertplayer="INSERT INTO `...`(....)
    VALUES (......')";
    if (!mysql_query($insertplayer,$db))
      {
      die('Error: ' . mysql_error());
      }
    $id = mysql_insert_id();
    echo 'done for player N°'.$id;
    mysql_close($db);
}
and the form i use:
<form action="insertplayer.php" method="post">
    <input type="text" name="nameplayer" />
    <input type="submit" value="ok" />
</form>
But when i do this, i have this error:
Catchable fatal error: Argument 1 passed to myFunction() must be an instance of string, string given, called in C:.... on line 23 and defined in C:...
I have this error with the int problem. How can i resolved it ?
Try removing the primitive data type from the function declaration. PHP does not require type hints for primitive data types.
function myFunction($name) {
    $db = mysql_connect("localhost", "root", "");
    mysql_select_db(...); 
    $insertplayer="INSERT INTO `...`(....)
    VALUES (......')";
    if (!mysql_query($insertplayer,$db))
      {
      die('Error: ' . mysql_error());
      }
    $id = mysql_insert_id();
    echo 'done for player N°'.$id;
    mysql_close($db);
}
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With