function GetID($newsTitle){
mysql_select_db($database_dbConnection, $dbConnection);
$query_rsGetId = sprintf("SELECT id FROM news WHERE title = %s", GetSQLValueString($newsTitle, "text"));
$rsGetId = mysql_query($query_rsGetId, $dbConnection) or die(mysql_error());
$row_rsGetId = mysql_fetch_assoc($rsGetId);
$totalRows_rsGetId = mysql_num_rows($rsGetId);
return $row_rsGetId['id'];
}
The above code will retrieve the ID when a string variable is passed to it and it will return the ID of that String once it matches in the database, but currently its not returning anything.
Thanks
mysql_*functions. They are deprecated and removed. 1. Checkvar_dump($query_rsGetId)to be the right query and put it in phpMyAdmin or something to verify that it's correct. 2.database_dbConnectionand$dbConnectionaren't defined inside the function.$database_dbConnectionand$dbConnectiondon't appear to be in the function scope, themysql_*functions don't exist in PHP7 and usingsprintfto interpolate the "title" is weird (and it'll not have the requisite apostrophes surrounding it) - best to start over.