Current location: Hot Scripts Forums » Programming Languages » PHP » how do i check to see if something already exists in a column in a DB


how do i check to see if something already exists in a column in a DB

Reply
  #1 (permalink)  
Old 01-06-04, 05:11 PM
tisza tisza is offline
Newbie Coder
 
Join Date: Dec 2003
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
how do i check to see if something already exists in a column in a DB

i am working on a signup script and i am stuck, i cant figure out how to check the database to see if the name already exists, this is hwat i have so far:

$checkuser = "SELECT username FROM users WHERE username = '$_POST[username]'";

if ( mysql_num_rows($checkuser, $conn) >= 1 ) {
echo "The name already exists. <a href='signup.html'>Back</a>";
}

btw the tabe is called users and the column is called username, when i use the aboce i get an error:

Warning: Wrong parameter count for mysql_num_rows() in c:\phpdev\www\login\signup.php on line 33

thx
Reply With Quote
  #2 (permalink)  
Old 01-06-04, 05:34 PM
musicalmidget's Avatar
musicalmidget musicalmidget is offline
Newbie Coder
 
Join Date: Jun 2003
Location: United Kingdom
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Hi, I changed the script slightly and this works for me...

PHP Code:

$checkuser "SELECT username FROM users WHERE username='$_POST[username]'";

$query mysql_query($checkuser);

if ( 
mysql_num_rows($query) >= ) {
echo 
"The name already exists. <a href='signup.html'>Back</a>";

__________________
Has anyone seen my signature?
Reply With Quote
  #3 (permalink)  
Old 01-06-04, 06:54 PM
tisza tisza is offline
Newbie Coder
 
Join Date: Dec 2003
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
thank you very much i have been stuck on that for a while
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP: check data transfer on certain directories? Agum PHP 7 12-30-03 03:58 AM
Upload file to table so ONLY files tied to primary key are displayed in record? grafixDummy PHP 4 12-20-03 04:28 PM
Using forms with auto increase column perleo PHP 3 10-11-03 04:37 PM
creating a column for ads dxoxb PHP 0 10-10-03 09:30 AM
How to check mail() MCM PHP 2 08-14-03 06:41 AM


All times are GMT -5. The time now is 08:21 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.