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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sorry, but I'm new to PHP - link question 1

Status
Not open for further replies.

Blutch

IS-IT--Management
Joined
Sep 19, 2002
Messages
203
Location
BE
I have the following. I want to create a link from a name value that I get from a MySQL database. When I click the link I want to put info for that name (also from the database) in another frame.

This is my code:

echo &quot;<a href=\&quot;right.php?&waarde=$bestand\&quot; target=&quot;rightframe&quot;>$row_RecordSet1['Naam']</a>&quot;<br>;

This doesn't work. What am I doing wrong?

Thx for any advice
 
&quot;This doesn't work&quot; is pretty vague. What does that phrase mean in this context.

I do know the line you have posted should produce a parse error, as the <br> at the end of the print statement is outside your quotes.

Also, you have a reference to an associative array inside quotes. Whereas you can normally put a variable reference inside quotes, even a reference to a numeric array element, an associative array reference will sometimes confuse the parser. I have better success using the &quot;.&quot; concatenation operator instead.



Want the best answers? Ask the best questions: TANSTAAFL!!
 
yeah some more info. and by the way sleipnir any leads on my problem?

Known is handfull, Unknown is worldfull
 
Right code:

echo &quot;<a href=\&quot;right.php?&waarde=$bestand\&quot; target=\&quot;rightframe\&quot;>&quot;.$row_RecordSet1['Naam'].&quot;</a>\&quot;<br>&quot;;
 
change that to:
echo &quot;<a href=\&quot;right.php?&waarde=$bestand\&quot; target=\&quot;rightframe\&quot;>&quot;.$row_RecordSet1['Naam'].&quot;</a><br>&quot;;




Known is handfull, Unknown is worldfull
 
Thanx vbkris, that works
 
I think there should be some more explanation with the solution so Blutch can learn what was wrong. Part of solving problems is to educate the person asking the question so they can solve similar problems in the future. Sharing the knowledge and experience in a forum like this is a great way to contribute to the overall level of understanding. Let's not hold back... ;)

Blutch
You might have realized by now that the error was in including unescaped double quotes in the echo statement. If you use double quotes to delineate the content of the echo statement you need to escape all double quotes inside.
You use the double quotes to allow substitution of variables within the echo statement. That's ok, however, using single quotes and concatenation can make the code clearer as the double quotes do not turn into a problem:
Code:
echo '<a href=&quot;right.php?&waarde='.$bestand.'&quot; target=&quot;rightframe&quot;>'.$row_RecordSet1['Naam'].'</a><br>';
 
Thx DRJ478, that's the way all questions should be handled.

I'm actually a systems engineer for networks ... and interested in php and mySQL, but still a newbie in that area.

So great that there are still people who want to share their knowledge.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top