943,832 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 2039
  • PHP RSS
You are currently viewing page 1 of this multi-page discussion thread
Dec 17th, 2007
0

check

Expand Post »
how do i check if a value is in my table?
like this:
INSERT INTO table_name (column1, column2,...)
VALUES (value1, value2,....)
and check if those values are in the table.
Similar Threads
Reputation Points: 10
Solved Threads: 1
Junior Poster in Training
kishou is offline Offline
52 posts
since Dec 2007
Dec 18th, 2007
0

Re: check

You need to do a select query..

select * from table_name where column1="value1" and column2="value2" ...

The answers to these sort of questions are in php/mysql tutorials all over the internet.
Reputation Points: 10
Solved Threads: 3
Newbie Poster
MickRip is offline Offline
7 posts
since Dec 2007
Dec 18th, 2007
0

Re: check

select * from table_name


this lis all the values in table .

g0 to w3schools.com this is very usefull site for bignner
Reputation Points: 5
Solved Threads: 5
Junior Poster
vssp is offline Offline
197 posts
since Jul 2006
Dec 18th, 2007
0

Re: check

Click to Expand / Collapse  Quote originally posted by MickRip ...
You need to do a select query..

select * from table_name where column1="value1" and column2="value2" ...

The answers to these sort of questions are in php/mysql tutorials all over the internet.
thanks but what im trying to do is like if the thing someone put in a form is already in the Table.
so what would it be like?
i was thinking it would be like this
elseif VALUES ('$_POST[Username]'==$_POST[Username])? this is just a guess.
Reputation Points: 10
Solved Threads: 1
Junior Poster in Training
kishou is offline Offline
52 posts
since Dec 2007
Dec 18th, 2007
0

Re: check

Click to Expand / Collapse  Quote originally posted by vssp ...
select * from table_name


this lis all the values in table .

g0 to w3schools.com this is very usefull site for bignner
yea already went there but thanks! if select *from Users then wat?
Reputation Points: 10
Solved Threads: 1
Junior Poster in Training
kishou is offline Offline
52 posts
since Dec 2007
Dec 18th, 2007
1

Re: check

use this command

$res=mysql_query("select * from table name where value1= $_post['value1']");

if (mysql_num_rows($res)>0)

{
$ans="value already exist";

}
else
{
$ans="....insert command...";
}
Reputation Points: 5
Solved Threads: 5
Junior Poster
vssp is offline Offline
197 posts
since Jul 2006
Dec 18th, 2007
0

Re: check

Click to Expand / Collapse  Quote originally posted by vssp ...
use this command

$res=mysql_query("select * from table name where value1= $_post['value1']");

if (mysql_num_rows($res)>0)

{
$ans="value already exist";

}
else
{
$ans="....insert command...";
}
thanks dude! So then it would look like this?
PHP Syntax (Toggle Plain Text)
  1. $res=mysql_query("SELECT * FROM registered_members=$_POST['Username']");
  2. if (mysql_num_rows($res)>0)
  3. {
  4. echo "Username is already taken!";
  5. }
  6. else
  7. {
Reputation Points: 10
Solved Threads: 1
Junior Poster in Training
kishou is offline Offline
52 posts
since Dec 2007
Dec 18th, 2007
0

Re: check

yes this is the correct syntax
Reputation Points: 5
Solved Threads: 5
Junior Poster
vssp is offline Offline
197 posts
since Jul 2006
Dec 18th, 2007
0

Re: check

ok then i get this error:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource.
Reputation Points: 10
Solved Threads: 1
Junior Poster in Training
kishou is offline Offline
52 posts
since Dec 2007
Dec 19th, 2007
0

Re: check

Click to Expand / Collapse  Quote originally posted by kishou ...
thanks dude! So then it would look like this?
PHP Syntax (Toggle Plain Text)
  1. $res=mysql_query("SELECT * FROM registered_members=$_POST['Username']");
  2. if (mysql_num_rows($res)>0)
  3. {
  4. echo "Username is already taken!";
  5. }
  6. else
  7. {
ok then i get this error:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource.
Thats because, you have your query wrong. Its missing a where clause.
$res=mysql_query("SELECT * FROM registered_members where username=$_POST['Username']");
Moderator
Featured Poster
Reputation Points: 524
Solved Threads: 356
Purple hazed!
nav33n is offline Offline
3,878 posts
since Nov 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: http://localhost problem
Next Thread in PHP Forum Timeline: upload files





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC