PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); $link = mysqli_connect("localhost", "my_user", "my_password", "world"); $city = "Amersfoort"; /* create a prepared statement */ $stmt = mysqli_stmt_init($link); mysqli_stmt_prepare($stmt, "SELECT District FROM City WHERE Name=?"); /* bind parameters for markers */ mysqli_stmt_bind_param($stmt, "s", $city); /* execute query */ mysqli_stmt_execute($stmt); /* bind result variables */ mysqli_stmt_bind_result($stmt, $district); /* fetch value */ mysqli_stmt_fetch($stmt); printf("%s is in district %s\n", $city, $district);
Copy Clear
Copy Format Clear
<?php // $mysqli is already declared as a working database connection by this sandbox $city = "Amersfoort"; /* create a prepared statement */ $stmt = mysqli_stmt_init($mysqli); mysqli_stmt_prepare($stmt, "SELECT District FROM City WHERE Name=?"); /* bind parameters for markers */ mysqli_stmt_bind_param($stmt, "s", $city); /* execute query */ mysqli_stmt_execute($stmt); /* bind result variables */ mysqli_stmt_bind_result($stmt, $district); /* fetch value */ mysqli_stmt_fetch($stmt); printf("%s is in district %s\n", $city, $district);
Show:  
Copy Clear