Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Oi,
function linkIDwithName ($id, $user)
{
$config = new config();
mysql_connect("$config->host", "$config->username", "$config->password") or die("cannot connect");
mysql_select_db("$config->db_name") or die("cannot select DB");
$search = mysql_query("SELECT * FROM user-image WHERE User='".$user."' AND ID='".$id."';");
if (mysql_affected_rows($search) <= 0) {
$sql = "INSERT INTO `XXX_plogin`.`user-image` (`User`, `ID`) VALUES ('$user', '$id');";
mysql_query($sql);
} else {
echo 'You already have this image in your profile!';
}
mysql_close();
}este é o erro que dá:
Warning: mysql_affected_rows(): supplied argument is not a valid MySQL-Link resource in /xxx/xxx/(ficheiro em que está a função).php on line 83
esta é a versão para nao dar o erro:
function linkIDwithName ($id, $user)
{
$config = new config();
mysql_connect("$config->host", "$config->username", "$config->password") or die("cannot connect");
mysql_select_db("$config->db_name") or die("cannot select DB");
$search = mysql_query("SELECT * FROM user-image WHERE User='".$user."' AND ID='".$id."';");
if ($search and mysql_affected_rows($search) <= 0 and mysql_errno() == 0) {
$sql = "INSERT INTO `xxx_plogin`.`user-image` (`User`, `ID`) VALUES ('$user', '$id');";
mysql_query($sql);
} else {
echo 'You already have this image in your profile!';
}
mysql_close();
}Carregando comentários...