mysql

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

    mysql

    Hello community!

    I am successfully using mysql connections and operations in more than one
    php file.
    But when I want to use this in an included (required("head er.inc.php")) php
    file but nothing happens except an error on
    mysql_select.
    Has mysql problems from included files or what could be the problem?

    with kind regards
    Wolfgang L.


  • Shawn Wilson

    #2
    Re: mysql

    Wolfgang Lang wrote:[color=blue]
    >
    > Hello community!
    >
    > I am successfully using mysql connections and operations in more than one
    > php file.
    > But when I want to use this in an included (required("head er.inc.php")) php
    > file but nothing happens except an error on
    > mysql_select.
    > Has mysql problems from included files or what could be the problem?
    >
    > with kind regards
    > Wolfgang L.[/color]

    I'm not sure I understand the syntax you're using. It should be something like
    this (note there is no "d" on the end of include or require):

    include ("header.inc.ph p");
    or
    require ("header.inc.ph p");

    If that's what you have, are you sure you have the path right? The syntax above
    should be used if the include file is in the same directory as the script you're
    including it in. Otherwise, you have to include path info. (i.e.
    "../../header.inc.php" or "/home/yourdirectory/header.inc.php" )

    Is the file actually being included? If you're not sure, type:

    echo "<BR><BR>!!!FOO !!!<BR><BR>";

    or similar on a line in the include file.

    If that's prints out okay, maybe you should describe the mysql error you're
    getting.

    Regards,
    Shawn

    --
    Shawn Wilson
    shawn@glassgian t.com

    Comment

    • Wolfgang Lang

      #3
      Re: mysql


      "Shawn Wilson" <shawn@glassgia nt.com> wrote in message
      news:3FF19139.9 61BD043@glassgi ant.com...[color=blue]
      > Wolfgang Lang wrote:[color=green]
      > >
      > > Hello community!
      > >
      > > I am successfully using mysql connections and operations in more than[/color][/color]
      one[color=blue][color=green]
      > > php file.
      > > But when I want to use this in an included (required("head er.inc.php"))[/color][/color]
      php[color=blue][color=green]
      > > file but nothing happens except an error on
      > > mysql_select.
      > > Has mysql problems from included files or what could be the problem?
      > >
      > > with kind regards
      > > Wolfgang L.[/color]
      >
      > I'm not sure I understand the syntax you're using. It should be something[/color]
      like[color=blue]
      > this (note there is no "d" on the end of include or require):
      >
      > include ("header.inc.ph p");
      > or
      > require ("header.inc.ph p");
      >
      > If that's what you have, are you sure you have the path right? The syntax[/color]
      above[color=blue]
      > should be used if the include file is in the same directory as the script[/color]
      you're[color=blue]
      > including it in. Otherwise, you have to include path info. (i.e.
      > "../../header.inc.php" or "/home/yourdirectory/header.inc.php" )
      >
      > Is the file actually being included? If you're not sure, type:
      >
      > echo "<BR><BR>!!!FOO !!!<BR><BR>";
      >
      > or similar on a line in the include file.
      >
      > If that's prints out okay, maybe you should describe the mysql error[/color]
      you're[color=blue]
      > getting.
      >
      > Regards,
      > Shawn[/color]

      the syntax is ok. the file is also included, because i get use of functions
      in that specific file in other php
      files.

      On my local machine i get:
      "2003 Can't connect to MySQL server on 'localhost' (10061)"

      An on the sourceforge server i get:
      "2002 Can't connect to local MySQL server through socket
      '/var/run/mysqld/mysqld.sock' (2)"

      you can see it on http://fsth.sourceforge.net


      Comment

      • Wolfgang Lang

        #4
        Re: mysql


        "Wolfgang Lang" <lang_wolfgang@ aon.at> wrote in message
        news:3ff198fe$0 $19356$91cee783 @newsreader01.h ighway.telekom. at...[color=blue]
        >
        > "Shawn Wilson" <shawn@glassgia nt.com> wrote in message
        > news:3FF19139.9 61BD043@glassgi ant.com...[color=green]
        > > Wolfgang Lang wrote:[color=darkred]
        > > >
        > > > Hello community!
        > > >
        > > > I am successfully using mysql connections and operations in more than[/color][/color]
        > one[color=green][color=darkred]
        > > > php file.
        > > > But when I want to use this in an included[/color][/color][/color]
        (required("head er.inc.php"))[color=blue]
        > php[color=green][color=darkred]
        > > > file but nothing happens except an error on
        > > > mysql_select.
        > > > Has mysql problems from included files or what could be the problem?
        > > >
        > > > with kind regards
        > > > Wolfgang L.[/color]
        > >
        > > I'm not sure I understand the syntax you're using. It should be[/color][/color]
        something[color=blue]
        > like[color=green]
        > > this (note there is no "d" on the end of include or require):
        > >
        > > include ("header.inc.ph p");
        > > or
        > > require ("header.inc.ph p");
        > >
        > > If that's what you have, are you sure you have the path right? The[/color][/color]
        syntax[color=blue]
        > above[color=green]
        > > should be used if the include file is in the same directory as the[/color][/color]
        script[color=blue]
        > you're[color=green]
        > > including it in. Otherwise, you have to include path info. (i.e.
        > > "../../header.inc.php" or "/home/yourdirectory/header.inc.php" )
        > >
        > > Is the file actually being included? If you're not sure, type:
        > >
        > > echo "<BR><BR>!!!FOO !!!<BR><BR>";
        > >
        > > or similar on a line in the include file.
        > >
        > > If that's prints out okay, maybe you should describe the mysql error[/color]
        > you're[color=green]
        > > getting.
        > >
        > > Regards,
        > > Shawn[/color]
        >
        > the syntax is ok. the file is also included, because i get use of[/color]
        functions[color=blue]
        > in that specific file in other php
        > files.
        >
        > On my local machine i get:
        > "2003 Can't connect to MySQL server on 'localhost' (10061)"
        >
        > An on the sourceforge server i get:
        > "2002 Can't connect to local MySQL server through socket
        > '/var/run/mysqld/mysqld.sock' (2)"
        >
        > you can see it on http://fsth.sourceforge.net[/color]

        sorry, did not use the right parameters.
        the actual error message is:"1044 Access denied for user:
        'fsth@sc8-pr-web4-b.sourceforge.n et' to database 'news'"
        but witz guestbook and news i can connect.


        Comment

        • Shawn Wilson

          #5
          Re: mysql

          Wolfgang Lang wrote:[color=blue]
          >
          > "Shawn Wilson" <shawn@glassgia nt.com> wrote in message
          > news:3FF19139.9 61BD043@glassgi ant.com...[color=green]
          > > Wolfgang Lang wrote:[color=darkred]
          > > >
          > > > Hello community!
          > > >
          > > > I am successfully using mysql connections and operations in more than[/color][/color]
          > one[color=green][color=darkred]
          > > > php file.
          > > > But when I want to use this in an included (required("head er.inc.php"))[/color][/color]
          > php[color=green][color=darkred]
          > > > file but nothing happens except an error on
          > > > mysql_select.
          > > > Has mysql problems from included files or what could be the problem?
          > > >
          > > > with kind regards
          > > > Wolfgang L.[/color]
          > >
          > > I'm not sure I understand the syntax you're using. It should be something[/color]
          > like[color=green]
          > > this (note there is no "d" on the end of include or require):
          > >
          > > include ("header.inc.ph p");
          > > or
          > > require ("header.inc.ph p");
          > >
          > > If that's what you have, are you sure you have the path right? The syntax[/color]
          > above[color=green]
          > > should be used if the include file is in the same directory as the script[/color]
          > you're[color=green]
          > > including it in. Otherwise, you have to include path info. (i.e.
          > > "../../header.inc.php" or "/home/yourdirectory/header.inc.php" )
          > >
          > > Is the file actually being included? If you're not sure, type:
          > >
          > > echo "<BR><BR>!!!FOO !!!<BR><BR>";
          > >
          > > or similar on a line in the include file.
          > >
          > > If that's prints out okay, maybe you should describe the mysql error[/color]
          > you're[color=green]
          > > getting.
          > >
          > > Regards,
          > > Shawn[/color]
          >
          > the syntax is ok. the file is also included, because i get use of functions
          > in that specific file in other php
          > files.
          >
          > On my local machine i get:
          > "2003 Can't connect to MySQL server on 'localhost' (10061)"
          >
          > An on the sourceforge server i get:
          > "2002 Can't connect to local MySQL server through socket
          > '/var/run/mysqld/mysqld.sock' (2)"
          >
          > you can see it on http://fsth.sourceforge.net[/color]

          The error I see is:
          1044 Access denied for user: 'fsth@sc8-pr-web1-b.sourceforge.n et' to database
          'news'

          Have you set up that user with the appropriate permissions?

          Are you able to connect to mysql on your local machine with other scripts?

          Regards,
          Shawn
          --
          Shawn Wilson
          shawn@glassgian t.com

          Comment

          • Wolfgang Lang

            #6
            Re: mysql


            "Shawn Wilson" <shawn@glassgia nt.com> wrote in message
            news:3FF19D99.1 B1AEB7A@glassgi ant.com...[color=blue]
            > Wolfgang Lang wrote:[color=green]
            > >
            > > "Shawn Wilson" <shawn@glassgia nt.com> wrote in message
            > > news:3FF19139.9 61BD043@glassgi ant.com...[color=darkred]
            > > > Wolfgang Lang wrote:
            > > > >
            > > > > Hello community!
            > > > >
            > > > > I am successfully using mysql connections and operations in more[/color][/color][/color]
            than[color=blue][color=green]
            > > one[color=darkred]
            > > > > php file.
            > > > > But when I want to use this in an included[/color][/color][/color]
            (required("head er.inc.php"))[color=blue][color=green]
            > > php[color=darkred]
            > > > > file but nothing happens except an error on
            > > > > mysql_select.
            > > > > Has mysql problems from included files or what could be the problem?
            > > > >
            > > > > with kind regards
            > > > > Wolfgang L.
            > > >
            > > > I'm not sure I understand the syntax you're using. It should be[/color][/color][/color]
            something[color=blue][color=green]
            > > like[color=darkred]
            > > > this (note there is no "d" on the end of include or require):
            > > >
            > > > include ("header.inc.ph p");
            > > > or
            > > > require ("header.inc.ph p");
            > > >
            > > > If that's what you have, are you sure you have the path right? The[/color][/color][/color]
            syntax[color=blue][color=green]
            > > above[color=darkred]
            > > > should be used if the include file is in the same directory as the[/color][/color][/color]
            script[color=blue][color=green]
            > > you're[color=darkred]
            > > > including it in. Otherwise, you have to include path info. (i.e.
            > > > "../../header.inc.php" or "/home/yourdirectory/header.inc.php" )
            > > >
            > > > Is the file actually being included? If you're not sure, type:
            > > >
            > > > echo "<BR><BR>!!!FOO !!!<BR><BR>";
            > > >
            > > > or similar on a line in the include file.
            > > >
            > > > If that's prints out okay, maybe you should describe the mysql error[/color]
            > > you're[color=darkred]
            > > > getting.
            > > >
            > > > Regards,
            > > > Shawn[/color]
            > >
            > > the syntax is ok. the file is also included, because i get use of[/color][/color]
            functions[color=blue][color=green]
            > > in that specific file in other php
            > > files.
            > >
            > > On my local machine i get:
            > > "2003 Can't connect to MySQL server on 'localhost' (10061)"
            > >
            > > An on the sourceforge server i get:
            > > "2002 Can't connect to local MySQL server through socket
            > > '/var/run/mysqld/mysqld.sock' (2)"
            > >
            > > you can see it on http://fsth.sourceforge.net[/color]
            >
            > The error I see is:
            > 1044 Access denied for user: 'fsth@sc8-pr-web1-b.sourceforge.n et' to[/color]
            database[color=blue]
            > 'news'
            >
            > Have you set up that user with the appropriate permissions?
            >
            > Are you able to connect to mysql on your local machine with other scripts?
            >
            > Regards,
            > Shawn[/color]

            yes, i connect to the same database and table on news.php with the same
            user/pass settings


            Comment

            • Agelmar

              #7
              Re: mysql

              Wolfgang Lang wrote:[color=blue]
              > Hello community!
              >
              > I am successfully using mysql connections and operations in more than
              > one php file.
              > But when I want to use this in an included
              > (required("head er.inc.php")) php file but nothing happens except an
              > error on
              > mysql_select.
              > Has mysql problems from included files or what could be the problem?
              >
              > with kind regards
              > Wolfgang L.[/color]

              For connections inside of an included file, make sure you do something like
              $MySQL_Link = mysql_connect(. ...);

              and then in the other files, you do
              mysql_query(... ., $MySQL_Link);

              if you leave off the handle for the database connections, you could have
              problems.


              Comment

              • Wolfgang Lang

                #8
                Re: mysql


                "Agelmar" <ifetteNOSPAM@c omcast.net> wrote in message
                news:bssb6i$uqs b$1@ID-30799.news.uni-berlin.de...[color=blue]
                > Wolfgang Lang wrote:[color=green]
                > > Hello community!
                > >
                > > I am successfully using mysql connections and operations in more than
                > > one php file.
                > > But when I want to use this in an included
                > > (required("head er.inc.php")) php file but nothing happens except an
                > > error on
                > > mysql_select.
                > > Has mysql problems from included files or what could be the problem?
                > >
                > > with kind regards
                > > Wolfgang L.[/color]
                >
                > For connections inside of an included file, make sure you do something[/color]
                like[color=blue]
                > $MySQL_Link = mysql_connect(. ...);
                >
                > and then in the other files, you do
                > mysql_query(... ., $MySQL_Link);
                >
                > if you leave off the handle for the database connections, you could have
                > problems.
                >[/color]
                but in the php files and the included file i use separate mysql
                connection/handles.
                i always connect, make my select,... and then close the connection.
                could this be a problem? should i use one connection for all queries?


                Comment

                • Agelmar

                  #9
                  Re: mysql

                  Wolfgang Lang wrote:[color=blue]
                  > "Agelmar" <ifetteNOSPAM@c omcast.net> wrote in message
                  > news:bssb6i$uqs b$1@ID-30799.news.uni-berlin.de...[color=green]
                  >> Wolfgang Lang wrote:[color=darkred]
                  >>> Hello community!
                  >>>
                  >>> I am successfully using mysql connections and operations in more
                  >>> than one php file.
                  >>> But when I want to use this in an included
                  >>> (required("head er.inc.php")) php file but nothing happens except an
                  >>> error on
                  >>> mysql_select.
                  >>> Has mysql problems from included files or what could be the problem?
                  >>>
                  >>> with kind regards
                  >>> Wolfgang L.[/color]
                  >>
                  >> For connections inside of an included file, make sure you do
                  >> something like $MySQL_Link = mysql_connect(. ...);
                  >>
                  >> and then in the other files, you do
                  >> mysql_query(... ., $MySQL_Link);
                  >>
                  >> if you leave off the handle for the database connections, you could
                  >> have problems.
                  >>[/color]
                  > but in the php files and the included file i use separate mysql
                  > connection/handles.
                  > i always connect, make my select,... and then close the connection.
                  > could this be a problem? should i use one connection for all queries?[/color]

                  It's certainly easier to just use one connection for all queries. Less work
                  on both servers, and less prone to errors (forgetting to re-open one,
                  mis-typing something somewhere etc.)


                  Comment

                  Working...