473,756 Members | 9,694 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
Jul 17 '05 #1
7 2176
CoralineSage wrote:
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

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
http://blog.dantripp.com/
Jul 17 '05 #2
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" <FV**********@s pammotel.com> wrote in message
news:9d******** *************** ***@posting.goo gle.com...
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


Jul 17 '05 #3
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

FV**********@sp ammotel.com (CoralineSage) wrote in message news:<9d******* *************** ****@posting.go ogle.com>...
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

Jul 17 '05 #4
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" <so*****@erols. com> wrote in message
news:1c******** *************** **@posting.goog le.com...
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

FV**********@sp ammotel.com (CoralineSage) wrote in message

news:<9d******* *************** ****@posting.go ogle.com>...
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

Jul 17 '05 #5
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" <pd*****@comcas t.net> wrote in message news:<Tc******* *************@c omcast.com>...
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" <so*****@erols. com> wrote in message
news:1c******** *************** **@posting.goog le.com...
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

FV**********@sp ammotel.com (CoralineSage) wrote in message

news:<9d******* *************** ****@posting.go ogle.com>...
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

Jul 17 '05 #6
FV**********@sp ammotel.com (CoralineSage) wrote in
news:9d******** *************** ***@posting.goo gle.com:
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.


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.
Jul 17 '05 #7
Eric Bohlman <eb******@earth link.net> wrote in message news:<Xn******* *************** ********@130.13 3.1.17>...
FV**********@sp ammotel.com (CoralineSage) wrote in
news:9d******** *************** ***@posting.goo gle.com:
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.


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.


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
Jul 17 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
3455
by: Joe | last post by:
I'm using Python 2.4 on Windows XP SP2. I'm trying to receive a command line argument that is a newline (\n) Here is the command line to use sample.py "\n" Here is a sample.py script
4
3180
by: lkrubner | last post by:
I'd like to write a PHP script to be used from the command line on a Unix machine. I'd like for the script to put together a string, turn it into a web page, print it, then return control the command line. Obviously it is quite easy to make a string that is valid HTML and send it to the printer. The tough part is making look like a web page. In particular, image tags should print out as images, not image tags. Does anyone have an idea...
4
6747
by: Rock | last post by:
I'm in the process of writing this program for complex numbers and I use DevC++. My professor on the other hand compiles on Borland 5.5. So I ocasionally save and run my work on Borland to see if it caught anything, it's very picky... Anyway, the code below works on Dev, and it compiles fine on Borland, but when I run it from borland, there is no output, no error, it just skips right over the freind ostream call. HELP! I'm new to this...
34
6870
by: Roman Mashak | last post by:
Hello, All! I'm implementing simple CLI (flat model, no tree-style menu etc.). Command line looks like this: <command> <param1> <param2> ... <paramN> (where N=1..4) And idea is pretty simple: 1) get whole string of input line 2) preset table of strings matching <command> 3) preset table of function calls
3
3037
by: Double Echo | last post by:
Hi all, I'm using PHP 4.4.2, and use PHP on both the command-line and the web. I am running PHP on SuSE 10 Linux , in a VMware 5.5 workstation, using Apache 2.0.55 , on my Dell laptop. Everything has been running flawlessly without problems. Very amazing to use VMware, it has worked beautifully. uname -a
10
8333
by: gh | last post by:
I have a short JS program that runs fine from the command line: #!/usr/bin/java org.mozilla.javascript.tools.shell.Main print("Hello World"); I saved it as HelloWorld.js. (It's the shabang that makes it a JavaScript program, not the .js.) However, if I start it from Safari or Firefox, I get the following message in the log:
51
4147
by: Ojas | last post by:
Hi!, I just out of curiosity want to know how top detect the client side application under which the script is getting run. I mean to ask the how to know whether the script is running under Command Prompt or Browser or some other application? Ojas.
7
9372
by: Jwe | last post by:
Hi, I've written a program which has both a command line interface and Windows form interface, however it isn't quite working correctly. When run from command line with no arguments it should display the Windows form. The form is being displayed but the command only returns when the form is closed. I want the command line to return immediately, leaving the form displayed.
0
1158
by: ryanmhuc | last post by:
I have a php script that runs perfect from the command line but when run over the web through apache the exec function has a return status of 1. Safe mode is turned off, the command can be executed by apache. Many commands like 'whoami', 'zip', will work but many others such as mysql will come back with no ouptput and a return status of 1. Any ideas?
0
9303
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9679
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9541
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7078
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6390
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4955
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5156
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3651
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2508
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.