vomitbomb Posted May 12, 2008 Share Posted May 12, 2008 Put this code together so it omits entries if a value hasn't been put in. It's not working and I'm getting: Parse error: syntax error, unexpected '.' in C:\htdocs\showorders.php on line 19 $sql = "SELECT * FROM orders WHERE lname='$search'"; $result = mysql_query($sql, $conn); $row = mysql_fetch_array( $result ); if(.$row['fname'] != NULL){ echo "Name: ".$row['fname']; } Anyone know another way I can do this? Link to comment https://forums.phpfreaks.com/topic/105223-solved-omitting-an-output-if-value-is-null/ Share on other sites More sharing options...
stopblackholes Posted May 12, 2008 Share Posted May 12, 2008 .$row['fname'] should be $row['fname'] Link to comment https://forums.phpfreaks.com/topic/105223-solved-omitting-an-output-if-value-is-null/#findComment-538786 Share on other sites More sharing options...
The Little Guy Posted May 12, 2008 Share Posted May 12, 2008 that is because you have period before the $row Try this: $sql = "SELECT * FROM orders WHERE lname='$search'"; $result = mysql_query($sql, $conn); $row = mysql_fetch_array( $result ); if($row['fname'] != NULL){ echo "Name: ".$row['fname']; } Link to comment https://forums.phpfreaks.com/topic/105223-solved-omitting-an-output-if-value-is-null/#findComment-538787 Share on other sites More sharing options...
vomitbomb Posted May 12, 2008 Author Share Posted May 12, 2008 cool thanks for that. just for reference? why is the dot in .$row? Link to comment https://forums.phpfreaks.com/topic/105223-solved-omitting-an-output-if-value-is-null/#findComment-538793 Share on other sites More sharing options...
The Little Guy Posted May 12, 2008 Share Posted May 12, 2008 because who ever made it made a mistake... basically it shouldn't be their. Link to comment https://forums.phpfreaks.com/topic/105223-solved-omitting-an-output-if-value-is-null/#findComment-538794 Share on other sites More sharing options...
vomitbomb Posted May 12, 2008 Author Share Posted May 12, 2008 lol I meant on: echo "Name: ".$row['fname']; Link to comment https://forums.phpfreaks.com/topic/105223-solved-omitting-an-output-if-value-is-null/#findComment-538827 Share on other sites More sharing options...
corbin Posted May 12, 2008 Share Posted May 12, 2008 It's simply PHP's concatenation character. PHP: "String" . "String" makes StringString Javascript: "String" + "String" makes StringString And so on... It's just the symbol in PHP that tells it to stick two strings together. Kind of ironic now that I think about it. A symbol which usually means end a sentence being used to stick two things together.... Link to comment https://forums.phpfreaks.com/topic/105223-solved-omitting-an-output-if-value-is-null/#findComment-538829 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.