473,405 Members | 2,210 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Function inop, but tosses no errors

HI,

Below is fully functional, non-functional code :^): In other words, it
works, but it doesn't do anything and darned if I can see why. None of
the 3 $email assignments result in any output. I just kept two
commented out so I could easily switch addresses for testing, thus the
"#"s. It does not kick out any errors and syntax checks valid with
tswebeditor (freebie).

I've sprinkled some echoes here and there to try to see what's running
but no help. I've indicated the ones that DO echo properly for me with
<-------.
I've checked syntax and pairing of brackets etc. in two differend
IDEs and all looks OK.
But, I've obviously pulled something stupid somwehere. It's pretty
simple code and I think it's evident what's going on so I haven't yet
added many comments. Basically, check the length left and right, how
many DOTs and @, and no dots where they shouldn't be.
But none of the if's result in any output & don't seem to be getting
run, indicating something pretty obvious I'm sure, just not obvious to
me!

Any Help?

Twayne
---------------------
<?php
$email="mi**@domain.com";
#$email="a@b.c";
#$email=".mine.@.domain..com";
echo "<br/>KB PFSTART"; <------- PFSTART etc are just ts names,
nothing more.
echo '<br/>using: ' . $email; <------- shows email address correctly
function validateEmail($email){
$output = "Might be valid.";
$email = trim($email);

If ((strlen($email)<5) || strstr($email," "))
{
$output = "too short, " . strlen($email) . " characters.";
echo "<br/>KB PF7";
}
If (substr_count($email, "@")<>1)
{
$output = "<one @.";
echo "<br/>KB PF6";
}
Else
{
If (strlen($halves[0])<1 || strlen($halves[1])<=3)
{
$output = "too few characters.";
echo "<br/>KB PF5";
}
echo "<br/>KB PF3";
If (substr($halves[0],0,1)=="." || substr($halves[0],-1,1)==".")
{
$output = " dot just before teh @.";
echo "<br/>KB PF5";
}
If (substr($halves[1],0,1)=="." || substr($halves[1],-1,1)==".")
{
$output = " dot on end of tld";
echo "<br/>KB PF5";
}
if (!strstr($halves[1],".") || strstr($halves[1],".."))
{
$output = " wrong number of dots in it.";
echo "<br/>KB PF5";
}
echo "<br/>KB PF7";
}
return $output;
}
echo '<br/>$output is ' . $output; # <--- $OUTPUT DOES NOT ECHO
echo "<br/>KB PFEND"; <-------
?>
--------- end ------------------


Jul 31 '08 #1
7 1044
PS Target: PHP 5.2.2 on remote server, using 5.2.5 locally on winXP Pro.
Sorry for the omission.
HI,

Below is fully functional, non-functional code :^): In other words,
it works, but it doesn't do anything and darned if I can see why. None
of the 3 $email assignments result in any output. I just kept
two commented out so I could easily switch addresses for testing,
thus the "#"s. It does not kick out any errors and syntax checks
valid with tswebeditor (freebie).

I've sprinkled some echoes here and there to try to see what's running
but no help. I've indicated the ones that DO echo properly for me
with <-------.
I've checked syntax and pairing of brackets etc. in two differend
IDEs and all looks OK.
But, I've obviously pulled something stupid somwehere. It's pretty
simple code and I think it's evident what's going on so I haven't yet
added many comments. Basically, check the length left and right, how
many DOTs and @, and no dots where they shouldn't be.
But none of the if's result in any output & don't seem to be getting
run, indicating something pretty obvious I'm sure, just not obvious to
me!

Any Help?

Twayne
---------------------
<?php
$email="mi**@domain.com";
#$email="a@b.c";
#$email=".mine.@.domain..com";
echo "<br/>KB PFSTART"; <------- PFSTART etc are just ts names,
nothing more.
echo '<br/>using: ' . $email; <------- shows email address correctly
function validateEmail($email){
$output = "Might be valid.";
$email = trim($email);

If ((strlen($email)<5) || strstr($email," "))
{
$output = "too short, " . strlen($email) . " characters.";
echo "<br/>KB PF7";
}
If (substr_count($email, "@")<>1)
{
$output = "<one @.";
echo "<br/>KB PF6";
}
Else
{
If (strlen($halves[0])<1 || strlen($halves[1])<=3)
{
$output = "too few characters.";
echo "<br/>KB PF5";
}
echo "<br/>KB PF3";
If (substr($halves[0],0,1)=="." || substr($halves[0],-1,1)==".")
{
$output = " dot just before teh @.";
echo "<br/>KB PF5";
}
If (substr($halves[1],0,1)=="." || substr($halves[1],-1,1)==".")
{
$output = " dot on end of tld";
echo "<br/>KB PF5";
}
if (!strstr($halves[1],".") || strstr($halves[1],".."))
{
$output = " wrong number of dots in it.";
echo "<br/>KB PF5";
}
echo "<br/>KB PF7";
}
return $output;
}
echo '<br/>$output is ' . $output; # <--- $OUTPUT DOES NOT ECHO
echo "<br/>KB PFEND"; <-------
>>
--------- end ------------------


Jul 31 '08 #2
..oO(Twayne)
>Below is fully functional, non-functional code :^): In other words, it
works, but it doesn't do anything and darned if I can see why. None of
the 3 $email assignments result in any output. I just kept two
commented out so I could easily switch addresses for testing, thus the
"#"s. It does not kick out any errors and syntax checks valid with
tswebeditor (freebie).

[...]
---------------------
<?php
$email="mi**@domain.com";
#$email="a@b.c";
#$email=".mine.@.domain..com";
echo "<br/>KB PFSTART"; <------- PFSTART etc are just ts names,
nothing more.
echo '<br/>using: ' . $email; <------- shows email address correctly
function validateEmail($email){
[...]
}
Maybe a stupid question, but do you actually call this function
somewhere?
>echo '<br/>$output is ' . $output; # <--- $OUTPUT DOES NOT ECHO
This line should cause an E_NOTICE error, since $output is not defined
anywhere.

Micha
Jul 31 '08 #3
.oO(Twayne)
>
>Below is fully functional, non-functional code :^): In other words,
it works, but it doesn't do anything and darned if I can see why.
None of the 3 $email assignments result in any output. I just kept
two commented out so I could easily switch addresses for testing,
thus the "#"s. It does not kick out any errors and syntax checks
valid with tswebeditor (freebie).

[...]
---------------------
<?php
$email="mi**@domain.com";
#$email="a@b.c";
#$email=".mine.@.domain..com";
echo "<br/>KB PFSTART"; <------- PFSTART etc are just ts names,
nothing more.
echo '<br/>using: ' . $email; <------- shows email address correctly
function validateEmail($email){
[...]
}

Maybe a stupid question, but do you actually call this function
somewhere?
Aww, darn it, yes; I forgot to inlcude the code. It's just a
validateEmail($email) statement after the "--...---" at the bottom of my
posted code.
>
>echo '<br/>$output is ' . $output; # <--- $OUTPUT DOES NOT ECHO

This line should cause an E_NOTICE error, since $output is not defined
anywhere.
Nope; and I do have errors turned on, including notices, in .ini.

$output is assigned multiple times as the function runs. e.g.
$output = "Might be valid."; and
$output = "too short, " . strlen($email) . " characters.";
.... etc.
Or did you mean something else I'm not catching on to?
Each if(...){...} has a " $output = "...
I thought possibly $email wasn't getting picked up or it was a scope
problem, but I don't see anything. Time for me to sleep on it again, I
think.

Thanks, Micha

Twayne
Aug 1 '08 #4
Did a Restart; now it's working! Damn! I already tried that once;
guess I didn't hold my mouth right. Ya gotta love windows!

HI,

Below is fully functional, non-functional code :^): In other words,
it works, but it doesn't do anything and darned if I can see why. None
of the 3 $email assignments result in any output. I just kept
two commented out so I could easily switch addresses for testing,
thus the "#"s. It does not kick out any errors and syntax checks
valid with tswebeditor (freebie).

I've sprinkled some echoes here and there to try to see what's running
but no help. I've indicated the ones that DO echo properly for me
with <-------.
I've checked syntax and pairing of brackets etc. in two differend
IDEs and all looks OK.
But, I've obviously pulled something stupid somwehere. It's pretty
simple code and I think it's evident what's going on so I haven't yet
added many comments. Basically, check the length left and right, how
many DOTs and @, and no dots where they shouldn't be.
But none of the if's result in any output & don't seem to be getting
run, indicating something pretty obvious I'm sure, just not obvious to
me!

Any Help?

Twayne
---------------------
<?php
$email="mi**@domain.com";
#$email="a@b.c";
#$email=".mine.@.domain..com";
echo "<br/>KB PFSTART"; <------- PFSTART etc are just ts names,
nothing more.
echo '<br/>using: ' . $email; <------- shows email address correctly
function validateEmail($email){
$output = "Might be valid.";
$email = trim($email);

If ((strlen($email)<5) || strstr($email," "))
{
$output = "too short, " . strlen($email) . " characters.";
echo "<br/>KB PF7";
}
If (substr_count($email, "@")<>1)
{
$output = "<one @.";
echo "<br/>KB PF6";
}
Else
{
If (strlen($halves[0])<1 || strlen($halves[1])<=3)
{
$output = "too few characters.";
echo "<br/>KB PF5";
}
echo "<br/>KB PF3";
If (substr($halves[0],0,1)=="." || substr($halves[0],-1,1)==".")
{
$output = " dot just before teh @.";
echo "<br/>KB PF5";
}
If (substr($halves[1],0,1)=="." || substr($halves[1],-1,1)==".")
{
$output = " dot on end of tld";
echo "<br/>KB PF5";
}
if (!strstr($halves[1],".") || strstr($halves[1],".."))
{
$output = " wrong number of dots in it.";
echo "<br/>KB PF5";
}
echo "<br/>KB PF7";
}
return $output;
}
echo '<br/>$output is ' . $output; # <--- $OUTPUT DOES NOT ECHO
echo "<br/>KB PFEND"; <-------
>>
--------- end ------------------


Aug 1 '08 #5
Just for clarity: The function functions; I didn't mean it has no other
problems<g>. Just in case a newbie decides to try it out; didn't want
to leave a false impression.

Twayne
Did a Restart; now it's working! Damn! I already tried that once;
guess I didn't hold my mouth right. Ya gotta love windows!

>HI,

Below is fully functional, non-functional code :^): In other words,
it works, but it doesn't do anything and darned if I can see why.
None of the 3 $email assignments result in any output. I just kept
two commented out so I could easily switch addresses for testing,
thus the "#"s. It does not kick out any errors and syntax checks
valid with tswebeditor (freebie).

I've sprinkled some echoes here and there to try to see what's
running but no help. I've indicated the ones that DO echo properly
for me with <-------.
I've checked syntax and pairing of brackets etc. in two differend
IDEs and all looks OK.
But, I've obviously pulled something stupid somwehere. It's pretty
simple code and I think it's evident what's going on so I haven't yet
added many comments. Basically, check the length left and right, how
many DOTs and @, and no dots where they shouldn't be.
But none of the if's result in any output & don't seem to be
getting run, indicating something pretty obvious I'm sure, just not
obvious to me!

Any Help?

Twayne
---------------------
<?php
$email="mi**@domain.com";
#$email="a@b.c";
#$email=".mine.@.domain..com";
echo "<br/>KB PFSTART"; <------- PFSTART etc are just ts names,
nothing more.
echo '<br/>using: ' . $email; <------- shows email address correctly
function validateEmail($email){
$output = "Might be valid.";
$email = trim($email);

If ((strlen($email)<5) || strstr($email," "))
{
$output = "too short, " . strlen($email) . " characters.";
echo "<br/>KB PF7";
}
If (substr_count($email, "@")<>1)
{
$output = "<one @.";
echo "<br/>KB PF6";
}
Else
{
If (strlen($halves[0])<1 || strlen($halves[1])<=3)
{
$output = "too few characters.";
echo "<br/>KB PF5";
}
echo "<br/>KB PF3";
If (substr($halves[0],0,1)=="." || substr($halves[0],-1,1)==".")
{
$output = " dot just before teh @.";
echo "<br/>KB PF5";
}
If (substr($halves[1],0,1)=="." || substr($halves[1],-1,1)==".")
{
$output = " dot on end of tld";
echo "<br/>KB PF5";
}
if (!strstr($halves[1],".") || strstr($halves[1],".."))
{
$output = " wrong number of dots in it.";
echo "<br/>KB PF5";
}
echo "<br/>KB PF7";
}
return $output;
}
echo '<br/>$output is ' . $output; # <--- $OUTPUT DOES NOT ECHO
echo "<br/>KB PFEND"; <-------
>>>
--------- end ------------------


Aug 1 '08 #6
..oO(Twayne)
>Maybe a stupid question, but do you actually call this function
somewhere?

Aww, darn it, yes; I forgot to inlcude the code. It's just a
validateEmail($email) statement after the "--...---" at the bottom of my
posted code.
OK.
>>echo '<br/>$output is ' . $output; # <--- $OUTPUT DOES NOT ECHO

This line should cause an E_NOTICE error, since $output is not defined
anywhere.

Nope; and I do have errors turned on, including notices, in .ini.

$output is assigned multiple times as the function runs. e.g.
$output = "Might be valid."; and
$output = "too short, " . strlen($email) . " characters.";
Yes, inside the function. But the line I mentioned was _outside_ the
function. But it's probably in the part you didn't post. ;)

Problem seems to be solved, but a last question: Did you change anything
in the PHP configuration? Such changes may require a restart of the web
server, but not a restart of the whole system. That's a bit strange.

Micha
Aug 1 '08 #7
.oO(Twayne)
>
>>Maybe a stupid question, but do you actually call this function
somewhere?

Aww, darn it, yes; I forgot to inlcude the code. It's just a
validateEmail($email) statement after the "--...---" at the bottom
of my posted code.

OK.
>>>echo '<br/>$output is ' . $output; # <--- $OUTPUT DOES NOT ECHO

This line should cause an E_NOTICE error, since $output is not
defined anywhere.

Nope; and I do have errors turned on, including notices, in .ini.

$output is assigned multiple times as the function runs. e.g.
$output = "Might be valid."; and
$output = "too short, " . strlen($email) . " characters.";

Yes, inside the function. But the line I mentioned was _outside_ the
function. But it's probably in the part you didn't post. ;)
OH, I see it. No, It was misplaced; I'd done a lot of rearranging and
screwed up replacing it properly.
>
Problem seems to be solved, but a last question: Did you change
anything in the PHP configuration? Such changes may require a restart
of the web server, but not a restart of the whole system. That's a
bit strange.

Micha
Hmm, I don't think so, but ; not exactly sure when I did it or if it
could count as a config change though: I did add a php.ini to my php
directory with only a "register_globals = off " line in it. AFAIK I
don't need it; don't even recall why I used it now, I'll have to check
my notes again. I did not change any config files though (ini, cfg,
etc).
However, restarting the server first should probably have been my
first effort, not the Restart; I'll have to remember that just for GPs.

Thanks again,

Twayne


Aug 1 '08 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Penn Markham | last post by:
Hello all, I am writing a script where I need to use the system() function to call htpasswd. I can do this just fine on the command line...works great (see attached file, test.php). When my...
2
by: Edvard Majakari | last post by:
Hi all ya unit-testing experts there :) Code I'm working on has to parse large and complex files and detect equally complex and large amount of errors before the contents of the file is fed to...
4
by: mangi03 | last post by:
Hi, I came acrosss g++ compile errors whenever I make a function call by reference and found out from the test program that compiler is treating the function argument differently when another...
2
by: Fabri | last post by:
I would like to ask you the following: I use Macromedia Dreamweaver as an editor for HTML and Js. It also writes some js functions to simply validate forms. I always used it with no bugs. ...
4
by: atv | last post by:
Whatis the proper way to handle errors from function calls? For example, i normally have a main function, with calls to mine or c functions. Should i check for errors in the functions called...
16
by: mdh | last post by:
May I ask the group the following: (Again, alas , from K&R) This is part of a function: while ( ( array1 = array2 ) != '\0' ); /* etc etc */ Is this the order that this is evaluated? ...
3
by: Aaron | last post by:
I have been searching the boards trying to find an answer to this question and no luck. I am using a query similar to this: Select count(col1) from table1 I was having a hard time accessing...
28
by: Bill | last post by:
Hello All, I am trying to pass a struct to a function. How would that best be accomplished? Thanks, Bill
4
by: barcaroller | last post by:
I am trying to adopt a model for calling functions and checking their return values. I'm following Scott Meyer's recommendation of not over-using exceptions because of their potential overhead. ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.