Page 1 of 1

what's wrong with my code?

Posted: Sun Apr 20, 2008 11:54 pm
by php_postgresql
echo "<a href='next.php?companyname= " '. $myrow['companyname'] .' "> </a>"






I'm trying to echo (this echo is inside a loop) the output from my database and i want them to be clickable links..... the 'companyname' serves as the unique value....pls. help me to correct the syntax and what should I do first before doing the code..should I initialize some stuff first?


thanks....

Re: what's wrong with my code?

Posted: Mon Apr 21, 2008 12:00 am
by Christopher
You have quote problems.

Code: Select all

echo '<a href="next.php?companyname='. $myrow['companyname'] .'"> </a>';

Re: what's wrong with my code?

Posted: Mon Apr 21, 2008 4:30 am
by markusn00b
I prefer to wrap array vars in curly brackets - keeps it clean looking!

Code: Select all

 
$_curly['brackets'] = "curly brackets";
echo "hello, im using {$_curly['brackets']} around my arrays!";
 

Re: what's wrong with my code?

Posted: Mon Apr 21, 2008 8:24 am
by N1gel
Your Single Quotation marks need to be inside the double quotes

like - " ' "

although without the spaces

Code: Select all

 
echo "<a href='next.php?companyname= '".$myrow['companyname']."'> </a>";
 

Re: what's wrong with my code?

Posted: Mon Apr 21, 2008 8:52 am
by aceconcepts
I find it useful to use outer single quotes:

Code: Select all

 
echo '<a href="next.php?companyname=' .$myrow['companyname']. '  "> </a>';
 
This method helps indicate the literal segments of the line using doubles quotes.