i can't seem to get the code working to determine how to check if a record exists in Mysql table. Im not very good at this but i'm learning. i would like to check if a certain barcode exists in my table called users.
i get the following error when i execute the code below.
Fatal error: Uncaught Error: Call to undefined function mysql_query() in C:\xampp\htdocs\watermeters\see.php:14 Stack trace: #0 {main} thrown in C:\xampp\htdocs\watermeters\see.php on line 14
See the code below. Can someone help me with this code?
<?php
$link = mysqli_connect("localhost", "root", "", "watermeter");
// Check connection
if($link === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
$query = "SELECT barcode from users where barcode='5645454'";
$result = mysql_query($link, $query);
if(mysql_num_rows($result) > 0)
{
// row exists. do whatever you would like to do.
} else {
// row does not exists. do whatever you would like to do.
}
// Close connection
mysqli_close($link);
?>