<?php
include("DBconnect.php");
$u="select count(username) as 'COUNTUSER' from users where username='shikha verma'";
$result = mysql_query($u);
while ($row = mysql_fetch_array($result))
{
echo $row[COUNTUSER];
}
/*if ($value[0]>0)
{
die("email already exist");
}*/
?>
the code inside the comment is not working please give me suggetions
Shikha_1 -4
Light Poster
Recommended Answers
Jump to PostEvolutionFallen, that's the worst way possible to accomplish this. You are fetching all the data from the user row just to count how many rows there are, never actually needing any of the data. It's a waste of resources. Shikha_1 had it right the first time; you are better of …
Jump to PostGranted, if you actually need the data you should of course fetch it, but it makes very little sense to be fetching data you don't need.
Normally it's probably not a great difference, but I've seen the method EvolutionFallen suggested used on tables with hundreds of fields, including huge text …
Jump to PostThis looks as though the query is for checking whether an user with that name already exists. Why should there be more than one user with the same username? I suppose you could, but this field is usually unique. Therefore, you probably don't even need a count, just a LIMIT …
All 12 Replies
pritaeas 2,194
¯\_(ツ)_/¯ Moderator Featured Poster
Shikha_1 -4
Light Poster
EvolutionFallen 107
Junior Poster
Atli 182
Posting Pro
broj1 356
Humble servant Featured Poster
Atli 182
Posting Pro
broj1 356
Humble servant Featured Poster
EvolutionFallen 107
Junior Poster
diafol
Atli 182
Posting Pro
diafol
kkbalwada 0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.