Jump to content

[SOLVED] Is there a way to pass $_SERVER vars to php5 cli?


smurraysb

Recommended Posts

Hi, I'm currently running php5 and mysql v5 and am trying to install an application via php5 cli, but I'm getting errors such as

 

PHP Notice:  Undefined index:  SERVER_PORT in /srv/www/htdocs/Sugar/install.php on line 178

PHP Notice:  Undefined index:  SERVER_NAME in /srv/www/htdocs/Sugar/install.php on line 181

PHP Notice:  Undefined index:  SERVER_PORT in /srv/www/htdocs/Sugar/install.php on line 181

 

These errors of usage of the $_SERVER are only in the file it's self, but it branches out to many files in the tree, which also used $_SERVER calls.  I feel this may adversely be effecting my MySQL queries.  I'm relatively new to php5 command line usage, so I guess the big question, is if there is a way to pass the $_SERVER array to the php5 cli?

 

Thanks for the help!

Link to comment
Share on other sites

Put simply, if this scriot your trying to install is intended for use through the web, its not likely going to be of much use to you on the command line.

 

Why exactly are you running this script via the command line?

Link to comment
Share on other sites

I need to run it through command line so that I can install the app remotely.  I'm fairly sure that the install should work via cli, because it's worked in older versions (this is a fairly new version I'm working on right now), and also the install runs fine, it's just after, when going to the index page for app usage, I'm getting MySQL errors.  This is the only thing that I can pin them too, after looking through a lot of the source PHP and seeing that $_SERVER calls are used quite often, I feel that command line silent install was overlooked a bit in this version.  But if I pass in the $_SERVER array, it should work as it's original intent is.  Only problem there is I'm not sure how to print this array.

 

Thanks again for the help

Link to comment
Share on other sites

'm fairly sure that the install should work via cli, because it's worked in older versions (this is a fairly new version I'm working on right now), and also the install runs fine, it's just after, when going to the index page for app usage, I'm getting MySQL errors.

 

And what errors are they exactly?

 

You can pass the $_SERVER array to a cli script but its kinda pointless. You'll need to make a wrapper script, call that via a server, then include your cli script. eg;

 

wrapper.php

<?php

  include 'your_cli_script.php';

?>

 

Call this via a server and it should bring the $_SERVER array into scope for the your_cli_script.php script, of course, its just as easy to request the script directly from a server itself.

Link to comment
Share on other sites

I see, so either which way, I $_SERVER requires browser usage.  Well, it was worth asking, haha.

 

As for the MySQL errors I'm getting

 

Query Failed: AND users.id = '1'::MySQL error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND users.id = '1'' at line 1

 

Which I'm thinking that somewhere along building the query out, there is an if statement that is based on a $_SERVER variable, causing a the query to fail.  You might recognize a problem more than I do though, any ideas?

 

EDIT:

Well, I'm off until Friday, I'll respond then, thanks again for the help!

Link to comment
Share on other sites

That's the funny part about it though

 

I did a grep -inHR "users\.id" *  and got nothing involving a MySQL query... I can't seem to find this particular query anywhere... baffling...

 

Well, for the most part, I think this is pretty much resolved

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.