php - Argument 1 passed to myFunction() must be an instance of string, string given, called in -


i have function:

function myfunction(string $name) {     $db = mysql_connect("localhost", "root", "");     mysql_select_db(...);       $insertplayer="insert `...`(....)     values (......')";     if (!mysql_query($insertplayer,$db))       {       die('error: ' . mysql_error());       }     $id = mysql_insert_id();     echo 'done player n°'.$id;     mysql_close($db); } 

and form use:

<form action="insertplayer.php" method="post">     <input type="text" name="nameplayer" />     <input type="submit" value="ok" /> </form> 

but when this, have error:

catchable fatal error: argument 1 passed myfunction() must instance of string, string given, called in c:.... on line 23 , defined in c:... 

i have error int problem. how can resolved ?

try removing primitive data type function declaration. php not require type hints primitive data types.

function myfunction($name) {     $db = mysql_connect("localhost", "root", "");     mysql_select_db(...);       $insertplayer="insert `...`(....)     values (......')";     if (!mysql_query($insertplayer,$db))       {       die('error: ' . mysql_error());       }     $id = mysql_insert_id();     echo 'done player n°'.$id;     mysql_close($db); } 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -