Stupid question

This is a discussion on Stupid question within the PHP General forums, part of the PHP Programming Forums category; I am trying to figure out why code that looks something like this : echo "connecting..."; $db = mysql_connect(xxx....


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-10-2006
WookieTim@gmail.com
 
Posts: n/a
Default Stupid question

I am trying to figure out why code that looks something like this :

echo "connecting...";
$db = mysql_connect(xxx.xx.xxx.x, 'xxx', 'xxxxxx');
if (!$db)
{
echo "Failure";
exit;
}
echo "Test";

is not working.

I know that PHP is up and running, since I get the "Connecting..."
printed out on the resulting page. However, I never see anything after
that. I would think that the mysql_connect would give me an error if it
wasn't connecting to the database. At least it would print "Failure" on
the page.

Instead what seems to be happening is that it gets to the connection
string and simply stops.

Any ideas?

Reply With Quote
  #2 (permalink)  
Old 05-11-2006
ZeldorBlat
 
Posts: n/a
Default Re: Stupid question


WookieTim@gmail.com wrote:
> I am trying to figure out why code that looks something like this :
>
> echo "connecting...";
> $db = mysql_connect(xxx.xx.xxx.x, 'xxx', 'xxxxxx');
> if (!$db)
> {
> echo "Failure";
> exit;
> }
> echo "Test";
>
> is not working.
>
> I know that PHP is up and running, since I get the "Connecting..."
> printed out on the resulting page. However, I never see anything after
> that. I would think that the mysql_connect would give me an error if it
> wasn't connecting to the database. At least it would print "Failure" on
> the page.
>
> Instead what seems to be happening is that it gets to the connection
> string and simply stops.
>
> Any ideas?


Because xxx.xx.xxx.x is a string and, as such, you need to put quotes
around it. The page dies because you get a parse error, but you
probably have display_errors turned off in php.ini so you don't see it.

Reply With Quote
  #3 (permalink)  
Old 05-11-2006
furby
 
Posts: n/a
Default Re: Stupid question

I thought of that - the non quotes was a transcription error (Don't
want poeple to be able to simply log onto this database). And shouldn't
errors show up as long as I don't use "@" in from of the "$db"?

Reply With Quote
  #4 (permalink)  
Old 05-11-2006
ZeldorBlat
 
Posts: n/a
Default Re: Stupid question


furby wrote:
> And shouldn't
> errors show up as long as I don't use "@" in from of the "$db"?


Not if you don't have error reporting (or display errors) enabled in
php.ini.

Reply With Quote
  #5 (permalink)  
Old 05-11-2006
furby
 
Posts: n/a
Default Re: Stupid question

Hmmmm.... I am running IIS (Not by choice - I'd much rather Apache when
i'm playing with PHP and MySQL) and I checked the PHP.ini file. Turns
out that Display_Errors was set to off. So I tunred it on.

But the problem is this - does IIS cache the PHP.ini file settings? If
so, is there a way to cause php to re-read the INI file without
restarting the server?

Reply With Quote
  #6 (permalink)  
Old 05-11-2006
Ehsan
 
Posts: n/a
Default Re: Stupid question

I don't think it can re-read the INI file without restarting your
server. As far as I know any change to server configuration or PHP
requires the server to be restarted in order to take effect.

If you run apache then you can use .htaccess file to control these INI
file values. This will not require you to restart your server
everytime. In .htaccess file the line:

php_value display_errors On

will override the value specified in the INI file.

Reply With Quote
  #7 (permalink)  
Old 05-15-2006
ZeldorBlat
 
Posts: n/a
Default Re: Stupid question


Ehsan wrote:
> I don't think it can re-read the INI file without restarting your
> server. As far as I know any change to server configuration or PHP
> requires the server to be restarted in order to take effect.
>
> If you run apache then you can use .htaccess file to control these INI
> file values. This will not require you to restart your server
> everytime. In .htaccess file the line:
>
> php_value display_errors On
>
> will override the value specified in the INI file.


You just need to restart IIS, not the entire machine.

Reply With Quote
  #8 (permalink)  
Old 05-15-2006
Ehsan
 
Posts: n/a
Default Re: Stupid question

Absolutely right. By server I meant only IIS Server, not the entire
machine!! Thanks for elaborating it ZeldorBlat. :)

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 12:05 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0