Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Something Missing from Custom Installation 1

Status
Not open for further replies.

ArtWerk

Programmer
Jul 31, 2006
66
US
I have installed PHP on a Windows IIS (ISAPI) version and I'm running into some problems. This is the first time i've personally installed PHP so I may have forgotten some things that I'm used to having.

To start off, I'll tell you what IS installed:
PHP 5.1.6
Collection of PECL modules for PHP 5.1.6
Zend Optimizer 3.0
MySQL 5.0

Now, there are 2 things I've noticed not working right:
1. for some reason this code doesn't work:
Code:
<?php
if($row_sqlquery['field'] != ""){
	echo "Field not blank";
} ?>
but this does:
Code:
<?php
echo $row_sqlquery['field'];
} ?>
(I've checked to make sure that a value is being passed into the $row variable from the SQL query)

2. Whenever I'm missing a ";" or haven't closed a }, I'm used to getting an error message (such as unexpected T_Variable blah blah on line 89), but I don't get those.

Am I missing some vital plugins or dlls for this installation that most people can't live without?
 
I suspect you're having some kind of parse error. The second code snippet, if it were a script in its entirety, would not work because the curly braces do not balance.



Want the best answers? Ask the best questions! TANSTAAFL!
 
2. Whenever I'm missing a ";" or haven't closed a }, I'm used to getting an error message (such as unexpected T_Variable blah blah on line 89), but I don't get those.


The OP is not getting an error message, i'm thinking its a php.ini config problem. something set to off that's supposed to be set to on.



----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Ok, like i mentioned (and vacunita commented on), I'm not getting any error messages at all.

Sorry about the useless } in the 2nd code. i just forgot to take it out, but it's not my problem.

See, when I say it doesn't work, it just doesn't work. i.e. in the middle of my page i have:
Code:
<?php if($row_event['description'] != ""){ ?>
	<tr height="40">
		<td align="right">Description:</td>
		<td align="left"><?php echo stripslashes($row_event['description']); ?>&nbsp;</td>
	</tr>
<?php } ?>

If the variable ($row_event['description']) has 200 characters or 0 characters, that section of code still doesn't show up. It's not a matter of syntax, it's something wrong with my installation or something. Unless PHP 5 doesn't allow if statements, then I've got something configured wrong, or am missing some dlls.
 
And when I do something wrong (like forget a semi-colon or brace), the page goes blank (and is supposed to have the error on it), but in the example above, there's no error and the rest of the page fully loads. It's almost as if the value for $row_event['description'] is always blank so it will never show up.
 
Ok, the PHP error reporting has been fixed. I guess by default display_errors is turned off (for some crazy security reason... :) anyway, i'm using the log file now, so that works.

as far as
Code:
print_r($row_event);

i get:
Code:
Array ( [eventid] => 5 [eventFull] => 2006-09-14 08:00:00 [title] => My Event Title [description] => [comments] => [eventType] => Normal [active] => 1 [typeid] => 1 [fulldate] => September 14, 2006 [fulltime] => 8:00 AM )
 
Sorry. The script snippet:

print '<pre>';
print_r ($row_event);
print '<pre>';

will produce much more readable output for a print_r() invocation.


Anyway, fFrom what I can see, $row_event['description'] is blank, so the if-clause (*if($row_event['description'] != "")*) should bypass the entire section. I would expect this behavior with your data.

Should $row_event['description'] be blank?



Want the best answers? Ask the best questions! TANSTAAFL!
 
In the example i gave you, it is blank, however in this example:
Code:
Array
(
    [eventid] => 8
    [eventFull] => 2006-09-28 08:00:00
    [title] => Event Title
    [description] => This is the event\'s description.
    [comments] => 
    [eventType] => Normal
    [active] => 1
    [typeid] => 1
    [fulldate] => September 28, 2006
    [fulltime] => 8:00 AM
)
Description is not blank. however with the if statement surrounding the section, it still doesn't show.
 
Sorry, but I just don't see how that input could cause the if-statement to skip over the code.

Does your code manipulate $row_event at all between the print_r() invocation and the if-statement beginning?



Want the best answers? Ask the best questions! TANSTAAFL!
 
why don't we try and force an output here - this is what i do to rule out any gremlins in conditionals which i can't spot (a security documents specialist once told me that he hated to see incomplete conditions: for every if there must be an else. He was drunk at the time though).

change this code
Code:
<?php if($row_event['description'] != ""){ ?>
    <tr height="40">
        <td align="right">Description:</td>
        <td align="left"><?php echo stripslashes($row_event['description']); ?>&nbsp;</td>
    </tr>
<?php } ?>

to
Code:
<?php if (empty($row_event['description'])) ?>
    <tr height="40">
        <td align="right">Description:</td>
        <td align="left">The description was empty &nbsp;</td>
    </tr>
<?php } else { ?>
    <tr height="40">
        <td align="right">Description:</td>
        <td align="left"><?php echo stripslashes($row_event['description']); ?>&nbsp;</td>
    </tr>
<?php } ?>
 
Nit: you left out the open curly bracket in the first line.
 
Ok, all of a sudden for some reason this just started working. I haven't changed any of the code at all. I have no idea what the heck was happening, but now it's working. Thanks a lot everyone for the help. Maybe fixing that error log problem did something... I don't know... O well...
 
Miros: you are absolutely right. i had originally entered the code using the alternative syntax but then realised that sparking off another debate was not going to be in the best interests of the OP or the forum ;-) so changed it to standard ... incorrectly

to artwerk: the great thing about electronics is that the microsoft fix of "turn it off, wait a bit and then turn it back on again" sometimes does work. It can NEVER work with coding errors though. so if nothing, absolutely nothing, has changed then the issue might well have been a cached version of the page (either browser or proxy, if used) from a previous code incarnation. turning your pc off, or shutting down all browser instances, should have flushed your cache. but also, in your code i would still prefer to have seen the use of the empty() function rather than a comparison to an empty string. empty() will also handle an unset variable and you also don't have to worry about unforeseen type equality.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top