Reputation:
I'm looking to update this from MySQL to MySQLi But I keep encountering errors while doing so. Basically this is a chunk of code for my dynamic page created from a link on another page.
$connect = mysql_connect('localhost', 'root', 'Password');
$select_db = mysql_select_db('playerslog');
$id = mysql_real_escape_string($_GET['UUID']);
//Remove LIMIT 1 to show/do this to all results.
$query = 'SELECT * FROM `playerslog` WHERE `UUID` = '.$id.' LIMIT 1';
$result = mysql_query($query);
$row = mysql_fetch_array($result);
// Echo page content
Any suggestions on how I could accomplish this? Thanks for your time!
Update as requested.
<?php
$connect = mysqli_connect('localhost', 'root', 'Password');
$select_db = mysqli_select_db('playerslog');
$id = mysqli_real_escape_string($_GET['UUID']);
//Remove LIMIT 1 to show/do this to all results.
$query = 'SELECT * FROM `playerslog` WHERE `UUID` = '.$id.' LIMIT 1';
$result = mysqli_query($query);
$row = mysqli_fetch_array($result);
// Echo page content
?>
Upvotes: 1
Views: 63
Reputation: 6684
You cannot simply replace mysql_* with mysqli_*. They have different syntaxes. You should for example fix how you execute the query. Mysqli expects two parameters: the connection and then the query. You pass just the query:
<?php
$connect = mysqli_connect('localhost', 'root', 'Password');
$select_db = mysqli_select_db('stats');
$id = mysqli_real_escape_string($_GET['UUID']);
//Remove LIMIT 1 to show/do this to all results.
$query = 'SELECT * FROM `playerslog` WHERE `UUID` = '.$id.' LIMIT 1';
$result = mysqli_query($connect, $query);
$row = mysqli_fetch_array($result);
// Echo page content
?>
Upvotes: 1