Re: [PHP] Displaying errors

2010-05-16 Thread Rene Veerman
On Sun, May 16, 2010 at 1:39 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.

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
-

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Displaying errors

2010-05-16 Thread Al



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
malki.cymbali...@weizmann.ac.il
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 = 'Error display and logging
on';
}

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.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] A weird problem that probably has a comma in the wrong spot....

2010-05-16 Thread Jason Pruim


On May 16, 2010, at 1:21 PM, Peter Lind wrote:


On 16 May 2010 19:14, 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:

$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:

$linkID = dbconnect($server, $username, $password, $database) or  
die("Could

not connect to host." . mysql_error());
?>


with that function defined as:

   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 :)



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] A weird problem that probably has a comma in the wrong spot....

2010-05-16 Thread Peter Lind
On 16 May 2010 19:14, 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:
>
>  $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:
>
>  $linkID = dbconnect($server, $username, $password, $database) or die("Could
> not connect to host." . mysql_error());
> ?>
>
>
> with that function defined as:
>
>  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

-- 

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


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] A weird problem that probably has a comma in the wrong spot....

2010-05-16 Thread Jason Pruim


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:



That code works...

When I change it to:




with that function defined as:



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?







--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] A weird problem that probably has a comma in the wrong spot....

2010-05-16 Thread Ashley Sheridan
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:
> 
>  $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:
> 
>  $linkID = dbconnect($server, $username, $password, $database) or  
> die("Could not connect to host." . mysql_error());
> ?>
> 
> 
> with that function defined as:
> 
>  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




Re: [PHP] Re: Displaying errors

2010-05-16 Thread Ashley Sheridan
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
> > malki.cymbali...@weizmann.ac.il
> > 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 = 'Error display and logging 
> on';
> }
> 
> 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




[PHP] A weird problem that probably has a comma in the wrong spot....

2010-05-16 Thread Jason Pruim

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:

$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:

$linkID = dbconnect($server, $username, $password, $database) or  
die("Could not connect to host." . mysql_error());

?>


with that function defined as:

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? :)

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: Displaying errors

2010-05-16 Thread Al



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
malki.cymbali...@weizmann.ac.il
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 = 'Error display and logging 
on';

}

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.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Displaying errors

2010-05-16 Thread Nilesh Govindarajan

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
malki.cymbali...@weizmann.ac.il
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
मेरा भारत महान !
मम भारत: महत्तम भवतु !

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Displaying errors

2010-05-16 Thread Ashley Sheridan
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
> malki.cymbali...@weizmann.ac.il 
> 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




Re: [PHP] Displaying errors

2010-05-16 Thread Nilesh Govindarajan

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
malki.cymbali...@weizmann.ac.il
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
मेरा भारत महान !
मम भारत: महत्तम भवतु !

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Displaying errors

2010-05-16 Thread Malka Cymbalista
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
malki.cymbali...@weizmann.ac.il 
08-934-3036