English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Hi,
Here is the contents of a php file I am writing:
require_once ('includes/mysql_connect.php');
$invitecode = $_GET["ic"];
$result = mysql_query("SELECT id FROM invitations WHERE status = 1");
if ($result == $invitecode) {
echo 'The result equals the invite code';
}
?>

I would like the script to see if the $_GET["ic"]; matches an id code inside the field "id". If it does, I would like it to echo 'The result equals the invite code'. How do I get this script to work?

Thanks in advance, I really appreciate it!

2006-08-23 07:10:03 · 1 answers · asked by Anonymous in Computers & Internet Programming & Design

1 answers

why don't you add the invite code to the query if you are checking against that?

SELECT id FROM invitations WHERE status='1' AND id='$invitecode'

(escape that invite code stuff to prevent SQL injection of course).

You can then just check and make sure the query returned a row - if ( mysql_num_rows( $result ) > 0 ){
//do stuff
}

2006-08-23 07:29:59 · answer #1 · answered by John J 6 · 1 0

fedest.com, questions and answers