php-general Digest 17 May 2010 05:19:21 -0000 Issue 6748
Topics (messages 305264 through 305275):
Re: Displaying errors
305264 by: Nilesh Govindarajan
305265 by: Ashley Sheridan
305266 by: Nilesh Govindarajan
305267 by: Al
305269 by: Ashley Sheridan
305274 by: Al
305275 by: Rene Veerman
A weird problem that probably has a comma in the wrong spot....
305268 by: Jason Pruim
305270 by: Ashley Sheridan
305271 by: Jason Pruim
305272 by: Peter Lind
305273 by: Jason Pruim
Administrivia:
To subscribe to the digest, e-mail:
[email protected]
To unsubscribe from the digest, e-mail:
[email protected]
To post to the list, e-mail:
[email protected]
----------------------------------------------------------------------
--- Begin Message ---
On 05/16/2010 05:09 PM, Malka Cymbalista wrote:
Hi all, we are running Apache 2.2.6 and PHP 5.2.6 on a Linux machine. If
someone gets an error when displaying a php web page, he does not get any error
message on the screen. The arror is written into the apache error log file,
but most users don't have access to the apache error logand i would like the
user to see the error on the screen.
Is there anything I can do?
thanks for any help.
Malka Cymbalista
Webmaster, Weizmann Institute of Science
[email protected]
08-934-3036
In php.ini, set error_reporting = On
Note if you override that somewhere, then change it at the overriding
point. Also, there may be some application specific setting, like in
Drupal, you can configure whether the errors are written to the dblog or
dblog and screen.
--
Nilesh Govindarajan
Site & Server Administrator
www.itech7.com
मेरा भारत महान !
मम भारत: महत्तम भवतु !
--- End Message ---
--- Begin Message ---
On Sun, 2010-05-16 at 14:39 +0300, Malka Cymbalista wrote:
> Hi all, we are running Apache 2.2.6 and PHP 5.2.6 on a Linux machine. If
> someone gets an error when displaying a php web page, he does not get any
> error message on the screen. The arror is written into the apache error log
> file, but most users don't have access to the apache error logand i would
> like the user to see the error on the screen.
> Is there anything I can do?
> thanks for any help.
>
>
>
> Malka Cymbalista
> Webmaster, Weizmann Institute of Science
> [email protected]
> 08-934-3036
>
By most users I assume you mean the developers, as it's not a very good
idea to display errors to actual users of your app (it gives information
away which could be used to break your system and allow them access to
your server)
There is a section inside the php.ini that you can use. Look for the
display_errors flag and set it to on. Just above or below that line
should be another which determines the exact type of errors to display.
The documentation within the ini file itself should show you some
examples.
Thanks,
Ash
http://www.ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
On 05/16/2010 05:21 PM, Nilesh Govindarajan wrote:
On 05/16/2010 05:09 PM, Malka Cymbalista wrote:
Hi all, we are running Apache 2.2.6 and PHP 5.2.6 on a Linux machine.
If someone gets an error when displaying a php web page, he does not
get any error message on the screen. The arror is written into the
apache error log file, but most users don't have access to the apache
error logand i would like the user to see the error on the screen.
Is there anything I can do?
thanks for any help.
Malka Cymbalista
Webmaster, Weizmann Institute of Science
[email protected]
08-934-3036
In php.ini, set error_reporting = On
Note if you override that somewhere, then change it at the overriding
point. Also, there may be some application specific setting, like in
Drupal, you can configure whether the errors are written to the dblog or
dblog and screen.
Oops oops oops. I put the wrong setting, change display_errors to On.
--
Nilesh Govindarajan
Site & Server Administrator
www.itech7.com
मेरा भारत महान !
मम भारत: महत्तम भवतु !
--- End Message ---
--- Begin Message ---
On 5/16/2010 7:39 AM, Malka Cymbalista wrote:
Hi all, we are running Apache 2.2.6 and PHP 5.2.6 on a Linux machine. If
someone gets an error when displaying a php web page, he does not get any error
message on the screen. The arror is written into the apache error log file,
but most users don't have access to the apache error logand i would like the
user to see the error on the screen.
Is there anything I can do?
thanks for any help.
Malka Cymbalista
Webmaster, Weizmann Institute of Science
[email protected]
08-934-3036
if(true) // TRUE for debug only
{
ini_set("display_errors", "on"); //use off if users will see them
error_reporting(E_ALL);
$error_reporting = '<span style="color:red">Error display and logging
on</span>';
}
I echo $error_reporting in the body of of my html page to remind me it is on.
This also creates an error log in the working dir.
--- End Message ---
--- Begin Message ---
On Sun, 2010-05-16 at 12:57 -0400, Al wrote:
>
> On 5/16/2010 7:39 AM, Malka Cymbalista wrote:
> > Hi all, we are running Apache 2.2.6 and PHP 5.2.6 on a Linux machine. If
> > someone gets an error when displaying a php web page, he does not get any
> > error message on the screen. The arror is written into the apache error
> > log file, but most users don't have access to the apache error logand i
> > would like the user to see the error on the screen.
> > Is there anything I can do?
> > thanks for any help.
> >
> >
> >
> > Malka Cymbalista
> > Webmaster, Weizmann Institute of Science
> > [email protected]
> > 08-934-3036
> >
> >
>
>
> if(true) // TRUE for debug only
> {
> ini_set("display_errors", "on"); //use off if users will see them
> error_reporting(E_ALL);
>
> $error_reporting = '<span style="color:red">Error display and logging
> on</span>';
> }
>
> I echo $error_reporting in the body of of my html page to remind me it is on.
>
> This also creates an error log in the working dir.
>
This won't work if the error is so severe as to prevent PHP from
correctly running. It's always best to set things in the php.ini file,
which should always be accessible on a local development machine.
Thanks,
Ash
http://www.ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
On 5/16/2010 1:10 PM, Ashley Sheridan wrote:
On Sun, 2010-05-16 at 12:57 -0400, Al wrote:
On 5/16/2010 7:39 AM, Malka Cymbalista wrote:
Hi all, we are running Apache 2.2.6 and PHP 5.2.6 on a Linux machine. If
someone gets an error when displaying a php web page, he does not get any error
message on the screen. The arror is written into the apache error log file,
but most users don't have access to the apache error logand i would like the
user to see the error on the screen.
Is there anything I can do?
thanks for any help.
Malka Cymbalista
Webmaster, Weizmann Institute of Science
[email protected]
08-934-3036
if(true) // TRUE for debug only
{
ini_set("display_errors", "on"); //use off if users will see them
error_reporting(E_ALL);
$error_reporting = '<span style="color:red">Error display and logging
on</span>';
}
I echo $error_reporting in the body of of my html page to remind me it is on.
This also creates an error log in the working dir.
This won't work if the error is so severe as to prevent PHP from
correctly running. It's always best to set things in the php.ini file,
which should always be accessible on a local development machine.
Thanks,
Ash
http://www.ashleysheridan.co.uk
True. But then you usually get a server 500 error anyhow.
--- End Message ---
--- Begin Message ---
On Sun, May 16, 2010 at 1:39 PM, Malka Cymbalista
<[email protected]> wrote:
> Hi all, we are running Apache 2.2.6 and PHP 5.2.6 on a Linux machine. If
> someone gets an error when displaying a php web page, he does not get any
> error message on the screen. The arror is written into the apache error log
> file, but most users don't have access to the apache error logand i would
> like the user to see the error on the screen.
> Is there anything I can do?
> thanks for any help.
I've just built an experimental component logAndHandler which will
display php errors in a developer & user-attractive way, but it is in
it's infancy.
For instance, some startup errors don't make it into the logAndHandler
window yet, which can be considered a bit of a problem for an error
handler ;)
I will continue work on it though, i'm using it myself for my
commercial projects.
http://mediabeez.ws/lah for a demo
http://mediabeez.ws/downloads (download "all my libraries" link)
--
---------------------------------
Greetings from Rene7705,
My free open source webcomponents:
http://code.google.com/u/rene7705/
http://mediabeez.ws/downloads (and demos)
http://www.facebook.com/rene7705
---------------------------------
--- End Message ---
--- Begin Message ---
Hi Everyone!
So I'm sitting here trying to get my RSS feed to work off of my main
database login script so that I can centralize the management of the
whole blasted thing, you know... stuff like only having the password
in one place to log into the DB :)
I can connect just fine if I include all the connection stuff locally
in my file, but when I try and include it so I don't have to reinvent
the wheel it says it can't connect.... Host, Username, & Password have
all been checked and doubled checked. And actually the database
connection script works just fine since I'm using it to pull the
content from my main page and that's working just fine...
Here's the code I'm using locally on the page:
<?PHP
$server = "localhost";
$username = "realusername";
$password = "realpass";
$database = "realdatabase";
$linkID = mysql_connect($server, $username, $password) or die("Could
not connect to host." . mysql_error());
mysql_select_db($database, $linkID) or die("Could not find
database." . mysql_error($linkID));
?>
That code works...
When I change it to:
<?PHP
$linkID = dbconnect($server, $username, $password, $database) or
die("Could not connect to host." . mysql_error());
?>
with that function defined as:
<?PHP
function dbconnect($server, $username, $password, $database) {
mysql_connect($server, $username, $password) or die("Unable to
connect: ".mysql_error());
mysql_select_db($database) or die("Unable to select
database:".mysql_error());
}
?>
that will not work on my rss feed. But it does work on my main page
which uses the dbconnect script. The only error that I'm getting is
the one set in my dbconnect call... "Could not connect to host".
So can anyone see where I'm missing my comma or semicolon? :)
--- End Message ---
--- Begin Message ---
On Sun, 2010-05-16 at 13:14 -0400, Jason Pruim wrote:
> Hi Everyone!
>
> So I'm sitting here trying to get my RSS feed to work off of my main
> database login script so that I can centralize the management of the
> whole blasted thing, you know... stuff like only having the password
> in one place to log into the DB :)
>
> I can connect just fine if I include all the connection stuff locally
> in my file, but when I try and include it so I don't have to reinvent
> the wheel it says it can't connect.... Host, Username, & Password have
> all been checked and doubled checked. And actually the database
> connection script works just fine since I'm using it to pull the
> content from my main page and that's working just fine...
>
>
> Here's the code I'm using locally on the page:
>
> <?PHP
> $server = "localhost";
> $username = "realusername";
> $password = "realpass";
> $database = "realdatabase";
>
>
> $linkID = mysql_connect($server, $username, $password) or die("Could
> not connect to host." . mysql_error());
> mysql_select_db($database, $linkID) or die("Could not find
> database." . mysql_error($linkID));
> ?>
>
> That code works...
>
> When I change it to:
>
> <?PHP
> $linkID = dbconnect($server, $username, $password, $database) or
> die("Could not connect to host." . mysql_error());
> ?>
>
>
> with that function defined as:
>
> <?PHP
> function dbconnect($server, $username, $password, $database) {
> mysql_connect($server, $username, $password) or die("Unable to
> connect: ".mysql_error());
>
> mysql_select_db($database) or die("Unable to select
> database:".mysql_error());
>
>
> }
> ?>
>
> that will not work on my rss feed. But it does work on my main page
> which uses the dbconnect script. The only error that I'm getting is
> the one set in my dbconnect call... "Could not connect to host".
>
> So can anyone see where I'm missing my comma or semicolon? :)
>
Are the MySQL ports open and available on both servers?
Thanks,
Ash
http://www.ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
On May 16, 2010, at 1:11 PM, Ashley Sheridan wrote:
On Sun, 2010-05-16 at 13:14 -0400, Jason Pruim wrote:
Hi Everyone!
So I'm sitting here trying to get my RSS feed to work off of my main
database login script so that I can centralize the management of the
whole blasted thing, you know... stuff like only having the password
in one place to log into the DB :)
I can connect just fine if I include all the connection stuff locally
in my file, but when I try and include it so I don't have to reinvent
the wheel it says it can't connect.... Host, Username, & Password
have
all been checked and doubled checked. And actually the database
connection script works just fine since I'm using it to pull the
content from my main page and that's working just fine...
Here's the code I'm using locally on the page:
<?PHP
$server = "localhost";
$username = "realusername";
$password = "realpass";
$database = "realdatabase";
$linkID = mysql_connect($server, $username, $password) or die("Could
not connect to host." . mysql_error());
mysql_select_db($database, $linkID) or die("Could not find
database." . mysql_error($linkID));
?>
That code works...
When I change it to:
<?PHP
$linkID = dbconnect($server, $username, $password, $database) or
die("Could not connect to host." . mysql_error());
?>
with that function defined as:
<?PHP
function dbconnect($server, $username, $password, $database) {
mysql_connect($server, $username, $password) or die("Unable to
connect: ".mysql_error());
mysql_select_db($database) or die("Unable to select
database:".mysql_error());
}
?>
that will not work on my rss feed. But it does work on my main page
which uses the dbconnect script. The only error that I'm getting is
the one set in my dbconnect call... "Could not connect to host".
So can anyone see where I'm missing my comma or semicolon? :)
Are the MySQL ports open and available on both servers?
Hey Ash,
Yes they are. It's on the same machine so ports shouldn't be an issue
I would think?
--- End Message ---
--- Begin Message ---
On 16 May 2010 19:14, Jason Pruim <[email protected]> wrote:
> Hi Everyone!
>
> So I'm sitting here trying to get my RSS feed to work off of my main
> database login script so that I can centralize the management of the whole
> blasted thing, you know... stuff like only having the password in one place
> to log into the DB :)
>
> I can connect just fine if I include all the connection stuff locally in my
> file, but when I try and include it so I don't have to reinvent the wheel it
> says it can't connect.... Host, Username, & Password have all been checked
> and doubled checked. And actually the database connection script works just
> fine since I'm using it to pull the content from my main page and that's
> working just fine...
>
>
> Here's the code I'm using locally on the page:
>
> <?PHP
> $server = "localhost";
> $username = "realusername";
> $password = "realpass";
> $database = "realdatabase";
>
>
> $linkID = mysql_connect($server, $username, $password) or die("Could not
> connect to host." . mysql_error());
> mysql_select_db($database, $linkID) or die("Could not find database." .
> mysql_error($linkID));
> ?>
>
> That code works...
>
> When I change it to:
>
> <?PHP
> $linkID = dbconnect($server, $username, $password, $database) or die("Could
> not connect to host." . mysql_error());
> ?>
>
>
> with that function defined as:
>
> <?PHP
> function dbconnect($server, $username, $password, $database) {
> mysql_connect($server, $username, $password) or die("Unable to connect:
> ".mysql_error());
>
> mysql_select_db($database) or die("Unable to select
> database:".mysql_error());
>
>
> }
> ?>
>
> that will not work on my rss feed. But it does work on my main page which
> uses the dbconnect script. The only error that I'm getting is the one set in
> my dbconnect call... "Could not connect to host".
>
> So can anyone see where I'm missing my comma or semicolon? :)
Your dbconnect function is not returning a value, defaulting to a null
return value. That means the or statement runs the die statement -
even though you're connecting.
Regards
Peter
--
<hype>
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
Flickr: http://www.flickr.com/photos/fake51
BeWelcome: Fake51
Couchsurfing: Fake51
</hype>
--- End Message ---
--- Begin Message ---
On May 16, 2010, at 1:21 PM, Peter Lind wrote:
On 16 May 2010 19:14, Jason Pruim <[email protected]> wrote:
Hi Everyone!
So I'm sitting here trying to get my RSS feed to work off of my main
database login script so that I can centralize the management of
the whole
blasted thing, you know... stuff like only having the password in
one place
to log into the DB :)
I can connect just fine if I include all the connection stuff
locally in my
file, but when I try and include it so I don't have to reinvent the
wheel it
says it can't connect.... Host, Username, & Password have all been
checked
and doubled checked. And actually the database connection script
works just
fine since I'm using it to pull the content from my main page and
that's
working just fine...
Here's the code I'm using locally on the page:
<?PHP
$server = "localhost";
$username = "realusername";
$password = "realpass";
$database = "realdatabase";
$linkID = mysql_connect($server, $username, $password) or
die("Could not
connect to host." . mysql_error());
mysql_select_db($database, $linkID) or die("Could not find
database." .
mysql_error($linkID));
?>
That code works...
When I change it to:
<?PHP
$linkID = dbconnect($server, $username, $password, $database) or
die("Could
not connect to host." . mysql_error());
?>
with that function defined as:
<?PHP
function dbconnect($server, $username, $password, $database) {
mysql_connect($server, $username, $password) or die("Unable to
connect:
".mysql_error());
mysql_select_db($database) or die("Unable to select
database:".mysql_error());
}
?>
that will not work on my rss feed. But it does work on my main page
which
uses the dbconnect script. The only error that I'm getting is the
one set in
my dbconnect call... "Could not connect to host".
So can anyone see where I'm missing my comma or semicolon? :)
Your dbconnect function is not returning a value, defaulting to a null
return value. That means the or statement runs the die statement -
even though you're connecting.
Hey Peter,
That was the problem... The reason it was working on the main page is
I didn't have a "Or die()" statement on the main page...
Now I'll be setting a return value on there so that it works for all
of them :)
Thanks for pointing out my stupidity :)
--- End Message ---