The comparison operator is ==. = means "assign". Try:

if ($num == 0) {
        foo(bar, baz);
}

AFAIK what your code means is "assign 0 to $num and then, if that worked,
print the error message."

HTH
Jon


-----Original Message-----
From: Jeff Oien [mailto:[EMAIL PROTECTED]]
Sent: 06 April 2001 17:51
To: PHP
Subject: [PHP] PHP/MySQL Code 


This code won't work. I'm trying to get an error if the username
is entered incorrectly but it won't go through the if brackets. I even
tried printing out $num and it's 0. I also tried 
if ($num = "0") {
if ($num = '0') {

<?php
include("connect.php");
$result=mysql_query("select * from table where
username='$username'",$connection) or die ("Can't do it");
$num = mysql_numrows($result);

if ($num = 0) {
        print "<html>error message etc.
        exit;
}

Jeff Oien

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]



**********************************************************************
'The information included in this Email is of a confidential nature and is 
intended only for the addressee. If you are not the intended addressee, 
any disclosure, copying or distribution by you is prohibited and may be 
unlawful. Disclosure to any party other than the addressee, whether 
inadvertent or otherwise is not intended to waive privilege or
confidentiality'

**********************************************************************

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to