By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,664 Members | 1,623 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,664 IT Pros & Developers. It's quick & easy.

PHP problem retrieving data

P: n/a
Wm
I'm not sure why this isn't working, but it's giving me no output. I have a
form which requests email and city to pull up a listing, then Email that
address with their password. I'm doing an extract($_POST) to get the data
from the previous form. When I test it I enter a known invalid email/city
combination, yet I get a blank area where the first message should be. This
is what's not working:

include('dbconnect.php');
if (Submit == "Remind Me") {
$query="SELECT ID,firstname,city,email,passwd from artists
WHERE email='$email' AND city='$city'";
$result=mysql_query($query) or die(mysql_error("Could not execute
query."));
// verify that the Email/city combination exists
if (mysql_num_rows($result) < 1) {
echo "<P>&nbsp;</P>
We cannot find that Email address and city combination in our
database.
Please use your browser's \"Back\" button and check your entry.<BR>
For best results, cut and paste the information from your listing to
ensure
that you don't have any typographical errors. If you continue to
have
difficulties, please <A HREF=\"mailto:We*******@domain.com\">
Email the Webmaster</A>.<BR>";
//break 2; (commented out in case it was causing the problem)
} else {
// pull listing from database
while($row = mysql_fetch_array($result)) {
$artistID = $row['artistID'];
$firstname = $row['firstname'];
$city= $row['city'];
$email = $row['email'];
$passwd = $row['passwd'];
// generate Email
$headers .= "From: Webmaster <We*******@domain.com>\n";
$headers .= "To: $firstname <$email>\n";
$headers .= "X-Sender: <We*******@domain.com>\n";
$headers .= "X-Mailer: domain.com\n"; //mailer
$headers .= "X-MSMail-Priority: Normal\n";
$headers .= "X-Priority: 3\n"; //1 UrgentMessage, 3 Normal
$headers .= "Return-Path: <We*******@domain.com>\n";
//Uncomment this to send html format
$headers .= "Content-Type: text/html; charset=iso-8859-1\n";
$message = "
...message text is here...
mail($to......);
}
Jul 16 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
On Sun, 10 Aug 2003 18:19:38 GMT, "Wm" <LA*******@hotmail.com> wrote:
I'm not sure why this isn't working, but it's giving me no output.

if (Submit == "Remind Me") {
If you'd had error_reporting turned up high enough, you'd have got a warning
similar to:

Use of undefined constant Submit, assuming string 'Submit'.

Since 'Submit' != "Remind Me", only the 'else' branch would ever execute.
} else {
// pull listing from database
while($row = mysql_fetch_array($result)) {


But $result was only defined inside the other branch of the if; surely it's
undefined here.

--
Andy Hassall (an**@andyh.co.uk) icq(5747695) (http://www.andyh.co.uk)
Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)
Jul 16 '05 #2

P: n/a
Wm
"Andy Hassall" <an**@andyh.co.uk> wrote in message
news:5n********************************@4ax.com...
On Sun, 10 Aug 2003 18:19:38 GMT, "Wm" <LA*******@hotmail.com> wrote:
I'm not sure why this isn't working, but it's giving me no output.

if (Submit == "Remind Me") {
If you'd had error_reporting turned up high enough, you'd have got a

warning similar to:

Use of undefined constant Submit, assuming string 'Submit'.

Since 'Submit' != "Remind Me", only the 'else' branch would ever execute.

The form that submits the data to this page has a value of "Remind Me" on
the submit button. I was trying to verify that the data I was dealing with
was submitted from that form. If they clicked the submit button on the first
page, this SHOULD be true -- it works with all my other sites.
} else {
// pull listing from database
while($row = mysql_fetch_array($result)) {


But $result was only defined inside the other branch of the if; surely

it's undefined here.


True -- maybe I could copy the query down...? but that shouldn't be
necessary if the data is coming from the submitted form, right?

Wm
Jul 16 '05 #3

P: n/a
On Sun, 10 Aug 2003 18:31:26 GMT, "Wm" <LA*******@hotmail.com> wrote:
"Andy Hassall" <an**@andyh.co.uk> wrote in message
news:5n********************************@4ax.com.. .
On Sun, 10 Aug 2003 18:19:38 GMT, "Wm" <LA*******@hotmail.com> wrote:
>I'm not sure why this isn't working, but it's giving me no output.
>
> if (Submit == "Remind Me") {


If you'd had error_reporting turned up high enough, you'd have got a

warning
similar to:

Use of undefined constant Submit, assuming string 'Submit'.

Since 'Submit' != "Remind Me", only the 'else' branch would ever execute.


The form that submits the data to this page has a value of "Remind Me" on
the submit button. I was trying to verify that the data I was dealing with
was submitted from that form. If they clicked the submit button on the first
page, this SHOULD be true -- it works with all my other sites.


No, read it again. You've missed the $.
> } else {
> // pull listing from database
> while($row = mysql_fetch_array($result)) {


But $result was only defined inside the other branch of the if; surely

it's
undefined here.


True -- maybe I could copy the query down...? but that shouldn't be
necessary if the data is coming from the submitted form, right?


Don't know, depends what you're passing.

But it sounds like you need to put error_reporting to E_ALL as both of these
should have displayed visible warnings.

--
Andy Hassall (an**@andyh.co.uk) icq(5747695) (http://www.andyh.co.uk)
Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)
Jul 16 '05 #4

P: n/a

On 10-Aug-2003, "Wm" <LA*******@hotmail.com> wrote:
"Andy Hassall" <an**@andyh.co.uk> wrote in message
news:5n********************************@4ax.com...
On Sun, 10 Aug 2003 18:19:38 GMT, "Wm" <LA*******@hotmail.com> wrote:
I'm not sure why this isn't working, but it's giving me no output.

if (Submit == "Remind Me") {


If you'd had error_reporting turned up high enough, you'd have got a

warning
similar to:

Use of undefined constant Submit, assuming string 'Submit'.

Since 'Submit' != "Remind Me", only the 'else' branch would ever
execute.


The form that submits the data to this page has a value of "Remind Me" on
the submit button. I was trying to verify that the data I was dealing with
was submitted from that form. If they clicked the submit button on the
first
page, this SHOULD be true -- it works with all my other sites.


Andy was trying to tell you that if (Submit should be if ($Submit

--
Tom Thackrey
www.creative-light.com
Jul 16 '05 #5

P: n/a
Wm
That was it -- ok, note to self: don't work anymore without coffee. THANK
YOU guys!!!

Wm

"Andy Hassall" <an**@andyh.co.uk> wrote in message
news:uq********************************@4ax.com...
On Sun, 10 Aug 2003 18:31:26 GMT, "Wm" <LA*******@hotmail.com> wrote:
"Andy Hassall" <an**@andyh.co.uk> wrote in message
news:5n********************************@4ax.com.. .
On Sun, 10 Aug 2003 18:19:38 GMT, "Wm" <LA*******@hotmail.com> wrote:

>I'm not sure why this isn't working, but it's giving me no output.
>
> if (Submit == "Remind Me") {

If you'd had error_reporting turned up high enough, you'd have got awarning
similar to:

Use of undefined constant Submit, assuming string 'Submit'.

Since 'Submit' != "Remind Me", only the 'else' branch would ever execute.


The form that submits the data to this page has a value of "Remind Me" on
the submit button. I was trying to verify that the data I was dealing with
was submitted from that form. If they clicked the submit button on the firstpage, this SHOULD be true -- it works with all my other sites.


No, read it again. You've missed the $.
} else {
> // pull listing from database
> while($row = mysql_fetch_array($result)) {

But $result was only defined inside the other branch of the if; surely

it's
undefined here.


True -- maybe I could copy the query down...? but that shouldn't be
necessary if the data is coming from the submitted form, right?


Don't know, depends what you're passing.

But it sounds like you need to put error_reporting to E_ALL as both of

these should have displayed visible warnings.

--
Andy Hassall (an**@andyh.co.uk) icq(5747695) (http://www.andyh.co.uk)
Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)

Jul 16 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.