I am trying to convert an old mysql_ code into mysqli_ renaming all to mysqli_ doesn't work, I keep getting "Warning: mysqli_query() expects at least 2 parameters, 1 given in" and "Warning: mysqli_error() expects parameter 1 to be mysqli, string given in" could anyone help me on this on how can I convert the code below to work. I can't find an easy to understand tutorial.
function TicketFetcher(){
$ticketsSQl = "SELECT tickets FROM tickets";
$ticketsResult = mysqli_query($ticketsSQl) or die("Failed sql is " .
$ticketsSQl . "<br>Invalid query: " . mysqli_error());
$tickets = mysqli_fetch_array($ticketsResult);
$tickets = $tickets[0];
return $tickets;
}
Because in MySQLi functions we have to pass the connection information in functions
like this
mysqli_query($conn,$ticketsSQl);
$conn =(host,username,password,dbname);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.