Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

SChaput

macrumors regular
Original poster
Jul 2, 2008
153
0
United States
I'm trying to incorporate a link in a new element of my page. Here is my code:
Code:
echo "var marker = createMarker(point, '" .addslashes($row['city']) . ", " . addslashes($row['state_name']) . "<a href='http://www.ihatemyroommate.net/?id=$id'>View</a>" . "');\n";

However, when loading the page up, nothing is displayed. If i remove the link aspect it all shows up fine, just with no link obviously. Am i using a wrong set of " or ' in my code?

Thanks
 
I'm trying to incorporate a link in a new element of my page. Here is my code:
Code:
echo "var marker = createMarker(point, '" .addslashes($row['city']) . ", " . addslashes($row['state_name']) . "<a href='http://www.ihatemyroommate.net/?id=$id'>View</a>" . "');\n";

However, when loading the page up, nothing is displayed. If i remove the link aspect it all shows up fine, just with no link obviously. Am i using a wrong set of " or ' in my code?

Thanks

I've looked at your quotes three times and they look fine so I'd be looking upstream to your database query. Can't say for sure without seeing the error message though.

Is this a private testing server? If it is, you might make your life easier by setting
Code:
display_errors = On
in your php.ini file.
 
I'm trying to incorporate a link in a new element of my page. Here is my code:
Code:
echo "var marker = createMarker(point, '" .addslashes($row['city']) . ", " . addslashes($row['state_name']) . "<a href='http://www.ihatemyroommate.net/?id=$id'>View</a>" . "');\n";

However, when loading the page up, nothing is displayed. If i remove the link aspect it all shows up fine, just with no link obviously. Am i using a wrong set of " or ' in my code?

Thanks

This is what you'll get:
Code:
var marker = createMarker(point, '[b]cityname[/b], [b]statename[/b]<a href='http://www.ihatemyroommate.net/?id=[b]12345[/b]'>View</a>');

(Note: example output from your variables are bolded)

Is that what you wanted?
Because we can see the single quote was started before the cityname, and ended after </a>. So the opening <a> tag was inside single quote.

And even if that's true, the single quote before http would cancel the single quote at the start of 'point' anyway


-stndn.
 
This is what you'll get:
Code:
var marker = createMarker(point, '[b]cityname[/b], [b]statename[/b]<a href='http://www.ihatemyroommate.net/?id=[b]12345[/b]'>View</a>');

(Note: example output from your variables are bolded)

Is that what you wanted?
Because we can see the single quote was started before the cityname, and ended after </a>. So the opening <a> tag was inside single quote.

And even if that's true, the single quote before http would cancel the single quote at the start of 'point' anyway


-stndn.

Wow, I hadn't even thought about the validity of the javascript.
If this is for google maps, this page might help you. Seems to be that point should be latitude and longitude and the second argument should only be the anchortag, which kind of makes the $row['city']and &row['state'] and thus PHP in that line redundant anyway.
 
On a Mac, if you are using Firefox, press

Cmd +Shift + J

and this will bring up the Error Console and click the tab for Errors (make sure you clear it, as it will have errors from every site you visited) then reload your page and check the Errors, it should show any Javascript errors that are being reported.

I believe there is also a Console on Safari, but not on OS X at the moment...
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.