RE: [PHP] PHP/MySQL Code
| From: | Jon Haworth | Date: | Fri, 06 Apr 2001 16:59:10 +0000 |
| Subject: | RE: [PHP] PHP/MySQL Code | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-47470@lists.php.net to get a copy of this message | ||
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:jeff@webdesigns1.com]
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: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net
**********************************************************************
'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'
**********************************************************************