PHP only runs from command line

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

    PHP only runs from command line

    Hi there, I know very little about PHP, but I was just curious to know
    why exactly would some PHP code run fine from the command line but not
    from the browser?

    I'm just curious. I was working with someone else's PHP code that
    supposedly created MySQL tables in a database and for some reason it
    just wouldn't create the tables at all (no specific error message).
    Someone suggested I run from the command line and when I did, it
    worked...

    Any help is truly appreciated.

    thanks
    CoralineSage
  • Dan Tripp

    #2
    Re: PHP only runs from command line

    CoralineSage wrote:
    [color=blue]
    > Hi there, I know very little about PHP, but I was just curious to know
    > why exactly would some PHP code run fine from the command line but not
    > from the browser?
    >
    > I'm just curious. I was working with someone else's PHP code that
    > supposedly created MySQL tables in a database and for some reason it
    > just wouldn't create the tables at all (no specific error message).
    > Someone suggested I run from the command line and when I did, it
    > worked...
    >
    > Any help is truly appreciated.
    >
    > thanks
    > CoralineSage[/color]


    The script you used was probably intended to run from the command line,
    so it likely didn't send HTML headers, and didn't include HTML tags in
    the output.

    It's analguous to the way perl scripts can run from a command
    line/terminal window vs. being run as a .cgi. The basic input/output
    methods are different (input from a command line parameter vs. a
    POST/GET; output to a terminal window vs. a web page).

    Hopefully that helped a bit. =)

    Regards,

    - Dan

    Comment

    • Savut

      #3
      Re: PHP only runs from command line

      Check your php errors log. Also is the code use some specific command line
      structure ? Is the php code showed on the browser ? Givce more info or more
      code please...

      Savut

      "CoralineSa ge" <FVZYSWBYIPBW@s pammotel.com> wrote in message
      news:9d066669.0 402111128.3e846 cfc@posting.goo gle.com...[color=blue]
      > Hi there, I know very little about PHP, but I was just curious to know
      > why exactly would some PHP code run fine from the command line but not
      > from the browser?
      >
      > I'm just curious. I was working with someone else's PHP code that
      > supposedly created MySQL tables in a database and for some reason it
      > just wouldn't create the tables at all (no specific error message).
      > Someone suggested I run from the command line and when I did, it
      > worked...
      >
      > Any help is truly appreciated.
      >
      > thanks
      > CoralineSage[/color]

      Comment

      • Phil Powell

        #4
        Re: PHP only runs from command line

        If you could produce the code we could see exactly what's going on,
        but I suspect that it has to do with mysql_connect() command in PHP
        that is not receiving the correct database connection information for
        mySQL to open.

        Phil

        FVZYSWBYIPBW@sp ammotel.com (CoralineSage) wrote in message news:<9d066669. 0402111128.3e84 6cfc@posting.go ogle.com>...[color=blue]
        > Hi there, I know very little about PHP, but I was just curious to know
        > why exactly would some PHP code run fine from the command line but not
        > from the browser?
        >
        > I'm just curious. I was working with someone else's PHP code that
        > supposedly created MySQL tables in a database and for some reason it
        > just wouldn't create the tables at all (no specific error message).
        > Someone suggested I run from the command line and when I did, it
        > worked...
        >
        > Any help is truly appreciated.
        >
        > thanks
        > CoralineSage[/color]

        Comment

        • Philip D Heady

          #5
          Re: PHP only runs from command line

          Sounds like root might own the files and apache can't execute them. Do a
          ls -la and see who has ownership. You might need to chown them for apache.


          "Phil Powell" <soazine@erols. com> wrote in message
          news:1cdca2a7.0 402111541.3d463 1f@posting.goog le.com...[color=blue]
          > If you could produce the code we could see exactly what's going on,
          > but I suspect that it has to do with mysql_connect() command in PHP
          > that is not receiving the correct database connection information for
          > mySQL to open.
          >
          > Phil
          >
          > FVZYSWBYIPBW@sp ammotel.com (CoralineSage) wrote in message[/color]
          news:<9d066669. 0402111128.3e84 6cfc@posting.go ogle.com>...[color=blue][color=green]
          > > Hi there, I know very little about PHP, but I was just curious to know
          > > why exactly would some PHP code run fine from the command line but not
          > > from the browser?
          > >
          > > I'm just curious. I was working with someone else's PHP code that
          > > supposedly created MySQL tables in a database and for some reason it
          > > just wouldn't create the tables at all (no specific error message).
          > > Someone suggested I run from the command line and when I did, it
          > > worked...
          > >
          > > Any help is truly appreciated.
          > >
          > > thanks
          > > CoralineSage[/color][/color]


          Comment

          • CoralineSage

            #6
            Re: PHP only runs from command line

            Hi All,

            Actually, the code is supposed to run from the browser (it's in the
            instructions for setting it up).

            Unfortunatelly I can't produce the code b/c it's paid for. Basically
            my company paid for this bulletin board and it was just really a pain
            to set it up. I had to find "creative" ways of making it work, like
            running from the command line instead of from the browser as it was
            listed in the instructions. Then, for each piece to work I had to go
            into the page that was complaining and comment out stuff so that it
            would work.

            Anyhow, I was just curious. I was extremely disappointed with the
            quality of the product that didn't run as smoothly as expected and
            required different versions of software than what they had specified.

            Also, just FYI, the MySQL connection did work, b/c prior to creating
            the tables it tests for the connection and it says it's ok. Also,
            after I finally installed the whole thing I can go ahead and create
            users, post messages, etc, and it all gets recorded into the database.

            Ok, guys, thanks a bunch for replying.

            CoralineSage


            "Philip D Heady" <pdheady@comcas t.net> wrote in message news:<TcCdnciM2 9b_WrfdRVn-uA@comcast.com> ...[color=blue]
            > Sounds like root might own the files and apache can't execute them. Do a
            > ls -la and see who has ownership. You might need to chown them for apache.
            >
            >
            > "Phil Powell" <soazine@erols. com> wrote in message
            > news:1cdca2a7.0 402111541.3d463 1f@posting.goog le.com...[color=green]
            > > If you could produce the code we could see exactly what's going on,
            > > but I suspect that it has to do with mysql_connect() command in PHP
            > > that is not receiving the correct database connection information for
            > > mySQL to open.
            > >
            > > Phil
            > >
            > > FVZYSWBYIPBW@sp ammotel.com (CoralineSage) wrote in message[/color]
            > news:<9d066669. 0402111128.3e84 6cfc@posting.go ogle.com>...[color=green][color=darkred]
            > > > Hi there, I know very little about PHP, but I was just curious to know
            > > > why exactly would some PHP code run fine from the command line but not
            > > > from the browser?
            > > >
            > > > I'm just curious. I was working with someone else's PHP code that
            > > > supposedly created MySQL tables in a database and for some reason it
            > > > just wouldn't create the tables at all (no specific error message).
            > > > Someone suggested I run from the command line and when I did, it
            > > > worked...
            > > >
            > > > Any help is truly appreciated.
            > > >
            > > > thanks
            > > > CoralineSage[/color][/color][/color]

            Comment

            • Eric Bohlman

              #7
              Re: PHP only runs from command line

              FVZYSWBYIPBW@sp ammotel.com (CoralineSage) wrote in
              news:9d066669.0 402121000.284c5 442@posting.goo gle.com:
              [color=blue]
              > Also, just FYI, the MySQL connection did work, b/c prior to creating
              > the tables it tests for the connection and it says it's ok. Also,
              > after I finally installed the whole thing I can go ahead and create
              > users, post messages, etc, and it all gets recorded into the database.[/color]

              That rather strongly suggests that whatever user the server runs as hasn't
              been granted permission to create tables but does have permission to access
              them. Remember that "running a program through the browser" is a rather
              sloppy bit of shorthand; it's the HTTP server that runs them, and the
              server is almost certainly not running as the same user who's running the
              browser.

              Comment

              • CoralineSage

                #8
                Re: PHP only runs from command line

                Eric Bohlman <ebohlman@earth link.net> wrote in message news:<Xns948DEF A3741Bebohlmano msdevcom@130.13 3.1.17>...[color=blue]
                > FVZYSWBYIPBW@sp ammotel.com (CoralineSage) wrote in
                > news:9d066669.0 402121000.284c5 442@posting.goo gle.com:
                >[color=green]
                > > Also, just FYI, the MySQL connection did work, b/c prior to creating
                > > the tables it tests for the connection and it says it's ok. Also,
                > > after I finally installed the whole thing I can go ahead and create
                > > users, post messages, etc, and it all gets recorded into the database.[/color]
                >
                > That rather strongly suggests that whatever user the server runs as hasn't
                > been granted permission to create tables but does have permission to access
                > them. Remember that "running a program through the browser" is a rather
                > sloppy bit of shorthand; it's the HTTP server that runs them, and the
                > server is almost certainly not running as the same user who's running the
                > browser.[/color]

                Actually Eric, the user the server runs as had been granted permission
                to create tables, as 1) an earlier version of this bulletin board had
                no problem creating the tables and 2) another one of the test includes
                creating and dropping tables.

                Thanks for the reply and apologies for not having provided more info.

                Coraline

                Comment

                Working...