[PHP-DB] elseif
hello and thank you for your time. will the below work to check if one field or the other is filled in upon submission? either contact_phone or contact_email is required but not both. best, addison $error = ; if ($name == ) { $error = $errorLIYou must enter a company name./LI; } if ($address == ) { $error = $errorLIYou must enter an address./LI; } if ($city == ) { $error = $errorLIYou must enter a city./LI; } if ($state == ) { $error = $errorLIYou must enter a state./LI; } if ($zip == ) { $error = $errorLIYou must enter a zip./LI; } if ($contact_phone == ) { $error = $errorLIYou must enter a contact phone number or email address./LI; } elseif ($contact_email == ) { $error = $errorLIYou must enter a contact phone number or email address./LI; } if ($error == ) { $query = insert into stores set -- Addison Ellis small independent publishing co. 114 B 29th Avenue North Nashville, TN 37203 (615) 321-1791 [EMAIL PROTECTED] [EMAIL PROTECTED] subsidiaries of small independent publishing co. [EMAIL PROTECTED] [EMAIL PROTECTED]
RE: [PHP-DB] elseif
You should probably replace $name == with strlen($name) 1. Also, you should probably used $error .= instead of $error = so that you can list all the errors instead of just the last one. Ryan -Original Message- From: Addison Ellis [mailto:[EMAIL PROTECTED]] Sent: Monday, January 27, 2003 5:26 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] elseif hello and thank you for your time. will the below work to check if one field or the other is filled in upon submission? either contact_phone or contact_email is required but not both. best, addison $error = ; if ($name == ) { $error = $errorLIYou must enter a company name./LI; } if ($address == ) { $error = $errorLIYou must enter an address./LI; } if ($city == ) { $error = $errorLIYou must enter a city./LI; } if ($state == ) { $error = $errorLIYou must enter a state./LI; } if ($zip == ) { $error = $errorLIYou must enter a zip./LI; } if ($contact_phone == ) { $error = $errorLIYou must enter a contact phone number or email address./LI; } elseif ($contact_email == ) { $error = $errorLIYou must enter a contact phone number or email address./LI; } if ($error == ) { $query = insert into stores set -- Addison Ellis small independent publishing co. 114 B 29th Avenue North Nashville, TN 37203 (615) 321-1791 [EMAIL PROTECTED] [EMAIL PROTECTED] subsidiaries of small independent publishing co. [EMAIL PROTECTED] [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] elseif
On Mon, Jan 27, 2003 at 06:26:06PM -0600, Addison Ellis wrote: hello and thank you for your time. will the below work to check if one field or the other is filled in upon submission? either contact_phone or contact_email is required but not both. best, addison I would use something like: $error = ; if (strlen(trim($name)) 1) { $error .= liYou must enter a company name.\n; } ... if (! ($contact_phone || $contact_email) ) { $error .= liYou must enter a contact phone number or email address.\n; } if (strlen(trim($contact_email)) 0 eregi('[a-z0-9_.-]+@([a-z0-9]+\.)+[a-z][a-z]+',$contact_email)) { $error .= liEmail address has an invalid format.\n; } if (!$error) { $q = INSERT INTO stores blah blah; ... } $error = ; if ($name == ) { $error = $errorLIYou must enter a company name./LI; } if ($address == ) { $error = $errorLIYou must enter an address./LI; } if ($city == ) { $error = $errorLIYou must enter a city./LI; } if ($state == ) { $error = $errorLIYou must enter a state./LI; } if ($zip == ) { $error = $errorLIYou must enter a zip./LI; } if ($contact_phone == ) { $error = $errorLIYou must enter a contact phone number or email address./LI; } elseif ($contact_email == ) { $error = $errorLIYou must enter a contact phone number or email address./LI; } if ($error == ) { $query = insert into stores set -- Addison Ellis small independent publishing co. 114 B 29th Avenue North Nashville, TN 37203 (615) 321-1791 [EMAIL PROTECTED] [EMAIL PROTECTED] subsidiaries of small independent publishing co. [EMAIL PROTECTED] [EMAIL PROTECTED] -- Paul Chvostek [EMAIL PROTECTED] Operations / Abuse / Whatever it.canada, hosting and development http://www.it.ca/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] elseif with header
I Larry is correct you havo to use (==) not (=). The first one is comparing two variables and the second is that var is equal to another var. Cumprimentos Bruno Pereira [EMAIL PROTECTED] -Original Message- From: Larry E. Ullman [mailto:[EMAIL PROTECTED]] Sent: terca-feira, 21 de Janeiro de 2003 0:29 To: Addison Ellis Cc: [EMAIL PROTECTED] Subject: Re: [PHP-DB] elseif with header if ($category = 2 and $subcategory = 52) { header(Location: http://www.vanderbilt.edu/register/ca/vacation_rentals.php;); } elseif ($category = 2 and $subcategory = 50) { header(Location: http://www.vanderbilt.edu/register/ca/rentals.php;); } , etc. for some reason all the elseifs are going to the if header. any input as to how i can correct this is greatly appreciated. You are using the assignment operator (=) instead of the equals comparison operator (==) which makes your if condition always true. Larry -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] elseif with header
if ($category = 2 and $subcategory = 52) { header(Location: http://www.vanderbilt.edu/register/ca/vacation_rentals.php;); } elseif ($category = 2 and $subcategory = 50) { header(Location: http://www.vanderbilt.edu/register/ca/rentals.php;); } , etc. for some reason all the elseifs are going to the if header. any input as to how i can correct this is greatly appreciated. You are using the assignment operator (=) instead of the equals comparison operator (==) which makes your if condition always true. Larry -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] elseif with header
You can just as simply include the files you need, there is no need for using the headers. Did the script return any errors? -Oorspronkelijk bericht- Van: Addison Ellis [mailto:[EMAIL PROTECTED]] Verzonden: dinsdag 21 januari 2003 1:19 Aan: [EMAIL PROTECTED] Onderwerp: [PHP-DB] elseif with header hello and thank you... i have two pages where on 1-category is selected. on 2 subcategory is selected. on submit from page two it goes to direct.php. there i have if ($category = 2 and $subcategory = 52) { header(Location: http://www.vanderbilt.edu/register/ca/vacation_rentals.php;); } elseif ($category = 2 and $subcategory = 50) { header(Location: http://www.vanderbilt.edu/register/ca/rentals.php;); } , etc. for some reason all the elseifs are going to the if header. any input as to how i can correct this is greatly appreciated. thank you again. addison -- Addison Ellis small independent publishing co. 114 B 29th Avenue North Nashville, TN 37203 (615) 321-1791 [EMAIL PROTECTED] [EMAIL PROTECTED] subsidiaries of small independent publishing co. [EMAIL PROTECTED] [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] elseif statement syntax
You probably have error reporting turned off in your php.ini file or you may be directing errors into your log file, try checking there. Why are you tacking or die(mysql_error()) on the end of each of your query assignments? You're just assigning a string to a variable so there's nothing to fail, or at least no mysql errors. -Steve On Wednesday, March 20, 2002, at 10:41 AM, Andrea Caldwell wrote: Hi All, I'm pretty new at this, so go easy on me please ;-) What is wrong w/ this syntax? If the search results are 0, it just displays a blank screen instead of echoing the error message if numresults ==0 or the mysql_error message. If data is found, everything is fine. Thanks in advance for your help! if($searchterm){ $query = select directory.realname, directory.phone, directory.ext, directory.phone2, directory.email, directory.location from directory where realname like '%.$searchterm.%' or die (mysql_error()); } elseif($location){ $query = select directory.realname, directory.phone, directory.ext, directory.phone2, directory.email, directory.location from directory where location like '%.$location.%' or die (mysql_error()); } else{ $query = select directory.realname, directory.phone, directory.ext, directory.phone2, directory.email, directory.location from directory where location like '%.$searchloc.%' or die (mysql_error()); } $result = mysql_query($query) or die (mysql_error()); $num_results = mysql_num_rows($result)or die (mysql_error());; if($num_results==0){ echo Sorry, nothing matched your search request. Please go back and try again.; } else { echo pspan class=stdtext_boldNumber of Entries Found: .$num_results./p/span; } -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] elseif statement syntax
Thanks for responding Steve, My error reporting is turned on, because I always get errors. I found the problem, I had two ;; at the end of one of the statements. Thanks- Andrea -Original Message- From: Steve Cayford [mailto:[EMAIL PROTECTED]] Sent: Wednesday, March 20, 2002 10:27 AM To: Andrea Caldwell Cc: [EMAIL PROTECTED] Subject: Re: [PHP-DB] elseif statement syntax You probably have error reporting turned off in your php.ini file or you may be directing errors into your log file, try checking there. Why are you tacking or die(mysql_error()) on the end of each of your query assignments? You're just assigning a string to a variable so there's nothing to fail, or at least no mysql errors. -Steve On Wednesday, March 20, 2002, at 10:41 AM, Andrea Caldwell wrote: Hi All, I'm pretty new at this, so go easy on me please ;-) What is wrong w/ this syntax? If the search results are 0, it just displays a blank screen instead of echoing the error message if numresults ==0 or the mysql_error message. If data is found, everything is fine. Thanks in advance for your help! if($searchterm){ $query = select directory.realname, directory.phone, directory.ext, directory.phone2, directory.email, directory.location from directory where realname like '%.$searchterm.%' or die (mysql_error()); } elseif($location){ $query = select directory.realname, directory.phone, directory.ext, directory.phone2, directory.email, directory.location from directory where location like '%.$location.%' or die (mysql_error()); } else{ $query = select directory.realname, directory.phone, directory.ext, directory.phone2, directory.email, directory.location from directory where location like '%.$searchloc.%' or die (mysql_error()); } $result = mysql_query($query) or die (mysql_error()); $num_results = mysql_num_rows($result)or die (mysql_error());; if($num_results==0){ echo Sorry, nothing matched your search request. Please go back and try again.; } else { echo pspan class=stdtext_boldNumber of Entries Found: .$num_results./p/span; } -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php