PHP problem retrieving data

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Wm

    PHP problem retrieving data

    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('dbconn ect.php');
    if (Submit == "Remind Me") {
    $query="SELECT ID,firstname,ci ty,email,passwd from artists
    WHERE email='$email' AND city='$city'";
    $result=mysql_q uery($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:W ebmaster@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_arr ay($result)) {
    $artistID = $row['artistID'];
    $firstname = $row['firstname'];
    $city= $row['city'];
    $email = $row['email'];
    $passwd = $row['passwd'];
    // generate Email
    $headers .= "From: Webmaster <Webmaster@doma in.com>\n";
    $headers .= "To: $firstname <$email>\n";
    $headers .= "X-Sender: <Webmaster@doma in.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: <Webmaster@doma in.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......) ;
    }


  • Andy Hassall

    #2
    Re: PHP problem retrieving data

    On Sun, 10 Aug 2003 18:19:38 GMT, "Wm" <LAshooter@hotm ail.com> wrote:
    [color=blue]
    >I'm not sure why this isn't working, but it's giving me no output.
    >
    > if (Submit == "Remind Me") {[/color]

    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.
    [color=blue]
    > } else {
    > // pull listing from database
    > while($row = mysql_fetch_arr ay($result)) {[/color]

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

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

    Comment

    • Wm

      #3
      Re: PHP problem retrieving data

      "Andy Hassall" <andy@andyh.co. uk> wrote in message
      news:5n3djvgkuc bpe3hmsdoh19n4e ubi7guiii@4ax.c om...[color=blue]
      > On Sun, 10 Aug 2003 18:19:38 GMT, "Wm" <LAshooter@hotm ail.com> wrote:
      >[color=green]
      > >I'm not sure why this isn't working, but it's giving me no output.
      > >
      > > if (Submit == "Remind Me") {[/color]
      >
      > If you'd had error_reporting turned up high enough, you'd have got a[/color]
      warning[color=blue]
      > similar to:
      >
      > Use of undefined constant Submit, assuming string 'Submit'.
      >
      > Since 'Submit' != "Remind Me", only the 'else' branch would ever execute.
      >[/color]

      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.
      [color=blue][color=green]
      > > } else {
      > > // pull listing from database
      > > while($row = mysql_fetch_arr ay($result)) {[/color]
      >
      > But $result was only defined inside the other branch of the if; surely[/color]
      it's[color=blue]
      > undefined here.
      >[/color]

      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


      Comment

      • Andy Hassall

        #4
        Re: PHP problem retrieving data

        On Sun, 10 Aug 2003 18:31:26 GMT, "Wm" <LAshooter@hotm ail.com> wrote:
        [color=blue]
        >"Andy Hassall" <andy@andyh.co. uk> wrote in message
        >news:5n3djvgku cbpe3hmsdoh19n4 eubi7guiii@4ax. com...[color=green]
        >> On Sun, 10 Aug 2003 18:19:38 GMT, "Wm" <LAshooter@hotm ail.com> wrote:
        >>[color=darkred]
        >> >I'm not sure why this isn't working, but it's giving me no output.
        >> >
        >> > if (Submit == "Remind Me") {[/color]
        >>
        >> If you'd had error_reporting turned up high enough, you'd have got a[/color]
        >warning[color=green]
        >> similar to:
        >>
        >> Use of undefined constant Submit, assuming string 'Submit'.
        >>
        >> Since 'Submit' != "Remind Me", only the 'else' branch would ever execute.
        >>[/color]
        >
        >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.[/color]

        No, read it again. You've missed the $.
        [color=blue][color=green][color=darkred]
        >> > } else {
        >> > // pull listing from database
        >> > while($row = mysql_fetch_arr ay($result)) {[/color]
        >>
        >> But $result was only defined inside the other branch of the if; surely[/color]
        >it's[color=green]
        >> undefined here.[/color]
        >
        >True -- maybe I could copy the query down...? but that shouldn't be
        >necessary if the data is coming from the submitted form, right?[/color]

        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 (andy@andyh.co. uk) icq(5747695) (http://www.andyh.co.uk)
        Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)

        Comment

        • Tom Thackrey

          #5
          Re: PHP problem retrieving data


          On 10-Aug-2003, "Wm" <LAshooter@hotm ail.com> wrote:
          [color=blue]
          > "Andy Hassall" <andy@andyh.co. uk> wrote in message
          > news:5n3djvgkuc bpe3hmsdoh19n4e ubi7guiii@4ax.c om...[color=green]
          > > On Sun, 10 Aug 2003 18:19:38 GMT, "Wm" <LAshooter@hotm ail.com> wrote:
          > >[color=darkred]
          > > >I'm not sure why this isn't working, but it's giving me no output.
          > > >
          > > > if (Submit == "Remind Me") {[/color]
          > >
          > > If you'd had error_reporting turned up high enough, you'd have got a[/color]
          > warning[color=green]
          > > similar to:
          > >
          > > Use of undefined constant Submit, assuming string 'Submit'.
          > >
          > > Since 'Submit' != "Remind Me", only the 'else' branch would ever
          > > execute.
          > >[/color]
          >
          > 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.[/color]

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

          --
          Tom Thackrey

          Comment

          • Wm

            #6
            Re: PHP problem retrieving data

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

            Wm

            "Andy Hassall" <andy@andyh.co. uk> wrote in message
            news:uq4djv08aa 3m9h28inci9nm2i 3uoq35e4t@4ax.c om...[color=blue]
            > On Sun, 10 Aug 2003 18:31:26 GMT, "Wm" <LAshooter@hotm ail.com> wrote:
            >[color=green]
            > >"Andy Hassall" <andy@andyh.co. uk> wrote in message
            > >news:5n3djvgku cbpe3hmsdoh19n4 eubi7guiii@4ax. com...[color=darkred]
            > >> On Sun, 10 Aug 2003 18:19:38 GMT, "Wm" <LAshooter@hotm ail.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[/color]
            > >warning[color=darkred]
            > >> similar to:
            > >>
            > >> Use of undefined constant Submit, assuming string 'Submit'.
            > >>
            > >> Since 'Submit' != "Remind Me", only the 'else' branch would ever[/color][/color][/color]
            execute.[color=blue][color=green][color=darkred]
            > >>[/color]
            > >
            > >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[/color][/color]
            with[color=blue][color=green]
            > >was submitted from that form. If they clicked the submit button on the[/color][/color]
            first[color=blue][color=green]
            > >page, this SHOULD be true -- it works with all my other sites.[/color]
            >
            > No, read it again. You've missed the $.
            >[color=green][color=darkred]
            > >> > } else {
            > >> > // pull listing from database
            > >> > while($row = mysql_fetch_arr ay($result)) {
            > >>
            > >> But $result was only defined inside the other branch of the if; surely[/color]
            > >it's[color=darkred]
            > >> undefined here.[/color]
            > >
            > >True -- maybe I could copy the query down...? but that shouldn't be
            > >necessary if the data is coming from the submitted form, right?[/color]
            >
            > Don't know, depends what you're passing.
            >
            > But it sounds like you need to put error_reporting to E_ALL as both of[/color]
            these[color=blue]
            > should have displayed visible warnings.
            >
            > --
            > Andy Hassall (andy@andyh.co. uk) icq(5747695) (http://www.andyh.co.uk)
            > Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)[/color]


            Comment

            Working...