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.

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.

select * from table_name


this lis all the values in table .

g0 to w3schools.com this is very usefull site for bignner

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.

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?

use this command

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

if (mysql_num_rows($res)>0)

{
$ans="value already exist";

}
else
{
$ans="....insert command...";
}

commented: Helped me alot with mysql! +1

use this command

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

if (mysql_num_rows($res)>0)

{
$ans="value already exist";

}
else
{
$ans="....insert command...";
}

thanks dude! So then it would look like this?

$res=mysql_query("SELECT * FROM registered_members=$_POST['Username']");
if (mysql_num_rows($res)>0)
{
echo "Username is already taken!";
}
else
{

yes this is the correct syntax

ok then i get this error:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource.

thanks dude! So then it would look like this?

$res=mysql_query("SELECT * FROM registered_members=$_POST['Username']");
if (mysql_num_rows($res)>0)
{
echo "Username is already taken!";
}
else
{

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']");

Thats because, you have your query wrong. Its missing a where clause. $res=mysql_query("SELECT * FROM registered_members where username=$_POST['Username']");

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource. still same error

Can you show us your script ?

still same err.

yea dont copy it though. please.

Dude! I can write my own script.. :D Anyway, here is the error.. $res=mysql_query("SELECT * FROM mailing_list where Email=$_POST[email]"); This should have been $res=mysql_query("SELECT * FROM mailing_list where Email='".$_POST[email]."'"); You should put your variable name in single quote if its a string.

Cheers,
Nav

Dude! I can write my own script.. :D Anyway, here is the error.. $res=mysql_query("SELECT * FROM mailing_list where Email=$_POST[email]"); This should have been $res=mysql_query("SELECT * FROM mailing_list where Email='".$_POST[email]."'"); You should put your variable name in single quote if its a string.

Cheers,
Nav

still same error. :( and for copying i mean everyone in general not just you. and yea i know you can make a script just like that.

Ok. I see the error. Its your select_db string. mysql_select_db("kishou_website", $connect);/ Its after your query. Put it above the query. :) This should fix it.

commented: just keeps on helping! +1

Ok. I see the error. Its your select_db string. mysql_select_db("kishou_website", $connect);/ Its after your query. Put it above the query. :) This should fix it.

dude thanks soo much! im a really big noob as you can see! you're like my savior! :D thanks!

:) you are welcome!

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.