הצורה בכלל שאתה עובד איתה היא לא טובה.
תעשה ככה:
PHP קוד:
<?php
$name=$_request['name'];
$link = mysql_connect('localhost', '', '');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
$db_selected = mysql_select_db('neri');
if (!$db_selected) {
die('Could not select database: ' . mysql_error());
}
$query = "SELECT name FROM `users` WHERE name = '{$name}' LIMIT 1";
$result = mysql_query($query);
if (!$result) {
die('Query failed: ' . mysql_error());
}
if(mysql_num_rows($result) > 0)
die("pick a new name");
mysql_free_result($result);
?>