$mysqli = new mysqli(\'localhost\', \'my_user\', \'my_password\', \'world\');
/* check connection */
if (mysqli_connect_errno()) {
printf(\"Connect failed: %s\\n\",
Yes, because mysqli_stmt::bind_param: Binds variables to a prepared statement as parameters
and it uses reference to these variables so that whenever you change them the change reflects on them.
bind_param
accepts references, if your unsure what references exactly are then click here for the extract named as "references explained"
This does mean, it is valid to set your variables after the bind_param
but then again, it's down to preference how you wish to do it. I for one, prefer declaring the variables prior to the bind
Little observation
The variables are declared prior to the execute, and as PHP works from top to bottom processing. When the variables are actully needed (on the execution) they would have already been set, if you declare your variables after the execute()
you will be prompted with SQL Failures and other unwanted php errors