I am trying to follow this previously answered question How to check if value already exists in MySQL database
Here is my code
<?php
$con=mysql_connect(Localhost,"mwtwoone_xbl","password","mwtwoone_xbl");
mysql_select_db( 'mwtwoone_xbl' );
$txn_id = $_GET['txn'];
echo $txn_id;
$checktxnID = mysql_query("SELECT txn_id from codes WHERE txn_id = '$txn_id'");
if (!$checktxnID) {
die('Query failed to execute for some reason');
}
if (mysql_num_rows($checktxnId) > 0) {
echo "User id exists already.";
$user = mysql_fetch_array($checktxnId);
print_r($user); // the data returned from the query
}
echo "User id doesnt exist";
mysql_close($con);
?>
$txn_id will be defined and I simply need to check if its value is already in table codes on column txn_id. Thanks for all the help, it is very appreciated.
Now when I access URL .php?txn=123 I get 123User id doesnt exist already. The problem is, multiple rows on table codes columb txn_id contain value 123!