what's wrong with my code?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
php_postgresql
Forum Newbie
Posts: 13
Joined: Sat Apr 19, 2008 9:37 am

what's wrong with my code?

Post 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....
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: what's wrong with my code?

Post by Christopher »

You have quote problems.

Code: Select all

echo '<a href="next.php?companyname='. $myrow['companyname'] .'"> </a>';
(#10850)
User avatar
markusn00b
Forum Contributor
Posts: 298
Joined: Sat Oct 20, 2007 2:16 pm
Location: York, England

Re: what's wrong with my code?

Post 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!";
 
User avatar
N1gel
Forum Commoner
Posts: 95
Joined: Sun Apr 30, 2006 12:01 pm

Re: what's wrong with my code?

Post 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>";
 
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Re: what's wrong with my code?

Post 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.
Post Reply