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....
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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? |
|
|||
|
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. |
|
|||
|
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? |
|
|||
|
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. |
|
|||
|
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. |