Page 1 of 1

Getting a NL before text in 'echo'

Posted: Fri Jan 02, 2009 10:20 pm
by lwoodsinc
I am getting a \n before the text in the following code. Is there some PHP option that would be doing this?

<?php require_once('Connections/test_connect.php'); ?>

<?php
$v=$_GET['vendorID'];
$c=$_GET['catID'];
mysql_select_db($database_test_connect, $test_connect);
$query_rs = "SELECT * FROM lnkcategoryvendor WHERE vendorID=$v AND catID=$c";
$rs = mysql_query($query_rs, $test_connect) or die(mysql_error());
$row_rs = mysql_fetch_assoc($rs);
$totalRows_rs = mysql_num_rows($rs);
if($totalRows_rs!=0) {
echo 'hit';
}
else {
echo 'nohit';
}
?>

TIA

Re: Getting a NL before text in 'echo'

Posted: Fri Jan 02, 2009 11:10 pm
by Syntac
Why do you have two PHP code blocks?

And yes, the space between them is what's causing the newline.

Re: Getting a NL before text in 'echo'

Posted: Sat Jan 03, 2009 10:05 am
by lwoodsinc
Interesting....

The double "PHP's" are because I copied this from a Dreamweaver generated page and didn't really spend any time analyzing it.

Thanks

Re: Getting a NL before text in 'echo'

Posted: Sat Jan 03, 2009 11:28 am
by Syntac
Dreamweaver? Bah! :D

Re: Getting a NL before text in 'echo'

Posted: Sat Jan 03, 2009 1:49 pm
by lwoodsinc
No Dreamweaver? Then do you use any other designer? Or, just hand code?

Also, while I'm at it, in a few cases I have done the following:

$vendorID = $_GET['vendorID'];

What is the PHP option that automatically defines the above; i.e., automatically lets you use the "$_GET" parameter as a variable?

TIA

Re: Getting a NL before text in 'echo'

Posted: Sat Jan 03, 2009 2:21 pm
by Syntac
1) I hand-code everything. It's much more satisfying. :)
2) That's register_globals, but don't use it. It's a massive security vulnerability if you don't code everything well. It isn't even very useful.

Re: Getting a NL before text in 'echo'

Posted: Sat Jan 03, 2009 2:28 pm
by lwoodsinc
Thanks for all of your input...

It's much appreciated.