I am trying to check if a code is already present in mySQL server and when I run it, it gives me this error: "mysql_result(): supplied argument is not a valid MySQL result resource". Would I need to use a mysql_query();?
Here is the code
<?php
include 'db.inc.php';
function is_chlink($url) {
return (preg_match("/chlink\.co\.cc/i", $url)) ? true : false;
}
function gen_code() {
$charset = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
return substr (str_shuffle($charset), 0, 6);
}
function code_exists($code) {
$code = mysql_real_escape_string($code);
$code_exists = mysql_query("SELECT COUNT(url_id)FROM url WHERE code='$code' LIMIT 1");
return (mysql_result($code_exists, 0) == 1) ? true : false;
}
?>