php scripts no longer working after upgrade

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • cwhite@theatomicmoose.ca

    php scripts no longer working after upgrade

    i recently upgraded from fedora core 5 to cent os 4.4 with php 4.3
    mysql 4.1 and apache 2.0.52, and all of the php scripts i had which
    called specific entries from mysql are no longer working

    if i had a link display_story.p hp?id=334 it would know do display the
    entry which matched id 334, my code to display the entry looks like
    this

    <?php
    $Host="localhos t";
    $User="user";
    $Password="pass word";
    $DBName="databa se";

    $Link=mysql_con nect($Host, $User, $Password);
    $Query="SELECT * from table WHERE sid=$id;
    $Result=mysql_d b_query($DBName ,$Query, $Link);
    while($Row=mysq l_fetch_array($ Result)){
    print("<table width=\"500\">\ n");
    print("<tr>\n") ;
    print("<td valign=\"bottom \">\n");
    print("<p class=\"page_ti tle\">$Row[title]\n");
    print("<p>\n");
    print("<i>$Row[hometext]</i>\n");
    print("</td>\n");
    print("<td>\n") ;
    $Topimage=$Row[topic];
    include 'top_image.php' ;
    print("</td>\n");
    print("</tr>\n");
    print("</table>\n");
    print("<p>\n");
    print("$Row[bodytext]\n");
    print("<div align=right><a href=\"javascri pt: history.go(-1)\">Back</
    a></div></td>\n");
    }
    mysql_close($Li nk);
    ?>

    the error message in my logs tell me that $Query="SELECT * from table
    WHERE sid=$id; is the problem

    [client 204.50.205.242] PHP Notice: Undefined variable: id in
    **********
    [client 204.50.205.242] PHP Warning: mysql_fetch_arr ay(): supplied
    argument is not a valid mysql result resource in
    *************** ************ on line 10

    i have tried turning on register_global s but the problem persists

    any ideas on how i can fix this in php.ini without having to go and re-
    write all of my scripts (i'm kind of lazy today)

    thanks

  • Erwin Moller

    #2
    Re: php scripts no longer working after upgrade

    cwhite@theatomi cmoose.ca wrote:
    i recently upgraded from fedora core 5 to cent os 4.4 with php 4.3
    mysql 4.1 and apache 2.0.52, and all of the php scripts i had which
    called specific entries from mysql are no longer working
    >
    if i had a link display_story.p hp?id=334 it would know do display the
    entry which matched id 334, my code to display the entry looks like
    this
    >
    <?php
    $Host="localhos t";
    $User="user";
    $Password="pass word";
    $DBName="databa se";
    >
    $Link=mysql_con nect($Host, $User, $Password);
    $Query="SELECT * from table WHERE sid=$id;
    $Result=mysql_d b_query($DBName ,$Query, $Link);
    while($Row=mysq l_fetch_array($ Result)){
    print("<table width=\"500\">\ n");
    print("<tr>\n") ;
    print("<td valign=\"bottom \">\n");
    print("<p class=\"page_ti tle\">$Row[title]\n");
    print("<p>\n");
    print("<i>$Row[hometext]</i>\n");
    print("</td>\n");
    print("<td>\n") ;
    $Topimage=$Row[topic];
    include 'top_image.php' ;
    print("</td>\n");
    print("</tr>\n");
    print("</table>\n");
    print("<p>\n");
    print("$Row[bodytext]\n");
    print("<div align=right><a href=\"javascri pt: history.go(-1)\">Back</
    a></div></td>\n");
    }
    mysql_close($Li nk);
    ?>
    >
    the error message in my logs tell me that $Query="SELECT * from table
    WHERE sid=$id; is the problem
    >
    [client 204.50.205.242] PHP Notice: Undefined variable: id in
    **********
    [client 204.50.205.242] PHP Warning: mysql_fetch_arr ay(): supplied
    argument is not a valid mysql result resource in
    *************** ************ on line 10
    >
    i have tried turning on register_global s but the problem persists
    >
    any ideas on how i can fix this in php.ini without having to go and re-
    write all of my scripts (i'm kind of lazy today)
    >
    thanks
    Hi,

    Did you print out the POST and GET array?
    Above your script:
    echo "POST contains:<pre>" ;
    print_r($_POST) ;
    echo "</pre>";
    echo "GET contains:<pre>" ;
    print_r($_GET);
    echo "</pre>";

    If of them contain the id, then your script relies on registering globals.
    If so, better fix that and get your data in the right way, with $_GET[] and
    $_POST[] supergloabls.

    If this is the case, I do NOT understand why enabling register_global s in
    php.ini didn't fix it. Did you restart your IIS, or signal apache after
    making changes into php.ini??

    Regards,
    Erwin Moller

    Comment

    • user@example.com

      #3
      Re: php scripts no longer working after upgrade

      cwhite@theatomi cmoose.ca wrote:
      [snip]
      >
      i have tried turning on register_global s but the problem persists
      >
      any ideas on how i can fix this in php.ini without having to go and re-
      write all of my scripts (i'm kind of lazy today)
      >
      thanks
      >
      Try popping a phpinfo() into the top of your script and checking
      register_global s really is On, if not then something is not right in
      configuration or its overridden somewhere (maybe a .htaccess)

      OR

      Do it properly and $id=$_GET["id"]; at the top of script

      OR

      Make your own function to create the vars and put this into an include
      file to be included at top of your page, but a bit risky security
      wise, something like (I write this straight into email so not tested):

      autoreg.php

      <?php
      foreach($_GET AS $key=>$value) {
      $$key=$value;
      }
      ?>

      test.php
      <?php
      require_once('a utoreg.php');
      if (isset($id)) echo "{$id}<br />";
      if (isset($name)) echo "{$name}<br />";
      ?>

      If you called this as myreg.php?id=1& name=Bob then it would print both
      the $id value and $bob value, you'd need to amend autoreg.php to include
      $_POST, $_SESSION etc. if you wanted and in the order you wanted as one
      would override the other if the key existed in say $_GET and $_SESSION etc.

      Personally, I'd write your code correctly for the newer PHP 5 standard
      if you can ;-)

      Comment

      • user@example.com

        #4
        Re: php scripts no longer working after upgrade

        If you called this as myreg.php?id=1& name=Bob then it would print both
        the $id value and $bob value, you'd need to amend autoreg.php to include
        $_POST, $_SESSION etc. if you wanted and in the order you wanted as one
        would override the other if the key existed in say $_GET and $_SESSION etc.
        I meant test.php?id=1&n ame=Bob obviously. Oops.

        Comment

        • Simon Stienen

          #5
          Re: php scripts no longer working after upgrade

          off topic (or generally on topic throughout all groups):

          Your client isn't properly configured. Please enter a real mail address to
          enable people to contact you. If you are afraid of spam, you have the
          possibility of creating an extra mail account just for your newsgroup
          stuff. Also please give us your realname, so we know who we're talking to.

          Thanks in advance.

          Comment

          • Erwin Moller

            #6
            Re: php scripts no longer working after upgrade

            Simon Stienen wrote:
            off topic (or generally on topic throughout all groups):
            >
            Your client isn't properly configured. Please enter a real mail address to
            enable people to contact you. If you are afraid of spam, you have the
            possibility of creating an extra mail account just for your newsgroup
            stuff. Also please give us your realname, so we know who we're talking to.
            >
            Thanks in advance.
            Why?
            Who cares what the real email of cwhite@atomicmo ose... is?
            If you have a response for him/her, you write it here like you did.

            I know I won't publish my real emails here.

            Regards,
            Erwin Moller

            Comment

            • Jerry Stuckle

              #7
              Re: php scripts no longer working after upgrade

              Simon Stienen wrote:
              off topic (or generally on topic throughout all groups):
              >
              Your client isn't properly configured. Please enter a real mail address to
              enable people to contact you. If you are afraid of spam, you have the
              possibility of creating an extra mail account just for your newsgroup
              stuff. Also please give us your realname, so we know who we're talking to.
              >
              Thanks in advance.
              I'm with Erwin. Although I have a munged email address here, I don't
              check it often. Ask in a newsgroup, expect a response in a newsgroup.

              If people want to contact me by email, fine. My normal hourly rates
              apply, payable in advance.

              --
              =============== ===
              Remove the "x" from my email address
              Jerry Stuckle
              JDS Computer Training Corp.
              jstucklex@attgl obal.net
              =============== ===

              Comment

              • Simon Stienen

                #8
                Re: php scripts no longer working after upgrade

                On 2007-04-04 04-52-22, Erwin Moller wrote:
                I know I won't publish my real emails here.
                Instead, you're redirecting more spam to spamyourself.co m since 2003. :P
                Under this aspect, user@example.co m is better, since it's pointing to a
                domain which is reserved by the DNS RFC. (Which I guess is not to his
                credit, but to the one of the Thunderbird developers.)

                Then again, you're at least giving us your name.

                However - as every better Usenet netiquette should state - private answers
                to the poster should not be posted as f'ups but as direct reply to the
                poster. If there is no mail given, this is (obviously) not possible. If
                someone doesn't want to be communicated with, he shouldn't post to NGs from
                the beginning.

                So *if* you're posting, you should make yourself contactable.

                Besides: user@example.co m might just be new to this and need a shove into
                the correct direction.

                Comment

                • Simon Stienen

                  #9
                  Re: php scripts no longer working after upgrade

                  On 2007-04-04 05-16-18, Simon Stienen wrote:
                  So *if* you're posting, you should make yourself contactable.
                  Besides: If *you* were contactable by mail, we wouldn't need to have this
                  off topic discussion here. :]

                  Comment

                  • Schraalhans Keukenmeester

                    #10
                    Re: php scripts no longer working after upgrade

                    X-noarchive: yes
                    Simon Stienen wrote:
                    off topic (or generally on topic throughout all groups):
                    >
                    Your client isn't properly configured. Please enter a real mail address to
                    enable people to contact you. If you are afraid of spam, you have the
                    possibility of creating an extra mail account just for your newsgroup
                    stuff. Also please give us your realname, so we know who we're talking to.
                    >
                    Thanks in advance.
                    I'm also with Erwin, and Jerry. For several reasons I don't even use my
                    real name here (none of them related to what I post on usenet). If that
                    is a problem, feel free to PLOINK me. I never (uhh, well once, right
                    Erwin, Jerry?) abused that relative anonimity on usenet, all my postings
                    are meant sincere, and mostly if not all on topic.

                    Personally I don't care a lot what name people post under. And I tried
                    using a real email address once, and still get a gazillion spam messages
                    a day related to that faux-pas.

                    My IP address has always been the same, and I don't mind. So with a
                    little handiwork you probably can find my real identity. Feel free.

                    You may even find my ip has once been abused by someone (I know his real
                    name and addy now), for a hate-posting addressed at himself hoping to be
                    able to pin it on me. My ISP, the police and myself still can only guess
                    how the perp managed to use their servers and my ip without having
                    access (to my knowledge) to my home or adsl line. He keeps denying btw.

                    If you ever feel the need to email me, just tell me and I'll gladly send
                    you a valid address.

                    Sh.

                    Comment

                    • Jerry Stuckle

                      #11
                      Re: php scripts no longer working after upgrade

                      Simon Stienen wrote:
                      On 2007-04-04 04-52-22, Erwin Moller wrote:
                      >I know I won't publish my real emails here.
                      >
                      Instead, you're redirecting more spam to spamyourself.co m since 2003. :P
                      Under this aspect, user@example.co m is better, since it's pointing to a
                      domain which is reserved by the DNS RFC. (Which I guess is not to his
                      credit, but to the one of the Thunderbird developers.)
                      >
                      Quite true.
                      Then again, you're at least giving us your name.
                      >
                      However - as every better Usenet netiquette should state - private answers
                      to the poster should not be posted as f'ups but as direct reply to the
                      poster. If there is no mail given, this is (obviously) not possible. If
                      someone doesn't want to be communicated with, he shouldn't post to NGs from
                      the beginning.
                      >
                      Netiquette says posts in a newsgroup should be answered in a newsgroup.
                      There is nothing which indicates you need to share your email address.

                      I do because I choose to. But even munged like it is, it still gets a
                      lot of spam. I don't check it often as it's only used for usenet stuff.

                      But I also know a lot of people in various newsgroups who don't share
                      their email addresses. No one else seems to have a problem with that.
                      And if you don't want to respond in a newsgroup, that's fine. But don't
                      criticize someone else for not having a valid email address.
                      So *if* you're posting, you should make yourself contactable.
                      >
                      So *if* you're responding, you should do it in the newsgroup.
                      Besides: user@example.co m might just be new to this and need a shove into
                      the correct direction.
                      Yes, he may be new. And it looks like he's doing perfectly fine like he is.

                      Besides - he wasn't the one with the problem. He was responding to
                      cwhite, who is the one with the problem.

                      --
                      =============== ===
                      Remove the "x" from my email address
                      Jerry Stuckle
                      JDS Computer Training Corp.
                      jstucklex@attgl obal.net
                      =============== ===

                      Comment

                      • Tyno Gendo

                        #12
                        Re: php scripts no longer working after upgrade

                        Schraalhans Keukenmeester wrote:
                        If you ever feel the need to email me, just tell me and I'll gladly send
                        you a valid address.
                        >
                        Sh.
                        Hi there!

                        Agreed, for reason of Netiquette I will repost here with a name just so
                        you know who is posting in future ;-)

                        I will keep user@example.co m however as it is reserved for use in
                        development and will guard me from spam, no need for a real address,
                        just causes lots of unwanted spam traffic.

                        Comment

                        Working...