Log in

View Full Version : parse erors in ajax link



fodo
02-28-2008, 04:27 PM
I am trying to use the dynamic ajax content script from DD.
I would like toreference php variables to select the conten to load.
I cant reslove my parse errors in writingout the a href tag.
Can anyone help please?



?>
<a href="javascript:ajaxpage(<?php' ./$p1'?>, 'contentarea');><img src=<?php './images/{$book['pix']}'?> border='0' width='80' height='100'/></a>"

<div id="contentarea"></div>
<?php

Nile
02-28-2008, 10:16 PM
Well, I think that you would need to echo it:

?>
<a href="javascript:ajaxpage(<?php echo' ./$p1'; ?>, 'contentarea');><img src=<?php echo './images/{$book['pix']}'; ?> border='0' width='80' height='100'/></a>"

<div id="contentarea"></div>
<?php

fodo
02-28-2008, 10:51 PM
Well, I think that you would need to echo it:

?>
<a href="javascript:ajaxpage(<?php echo' ./$p1'; ?>, 'contentarea');><img src=<?php echo './images/{$book['pix']}'; ?> border='0' width='80' height='100'/></a>"

<div id="contentarea"></div>
<?php
Hi Nile, thanks for that.
It works in part.
This works;

<a href="javascript:ajaxpage('<?php echo $p1?>', 'contentarea');">Link</a>

However, the image tag screws it up with a parse error, code below


<a href="javascript:ajaxpage('<?php echo $p1?>', 'contentarea');"><img src=<?php echo './images/{$book['pix']}'; ?> border='0' width='80' height='100'/></a>

Any suggestions welcome.

Nile
02-29-2008, 12:02 AM
Try this:


<a href="javascript:ajaxpage('<?php echo $p1?>', 'contentarea');"><img src=<?php echo './images/{$book[\'pix\']}'; ?> border='0' width='80' height='100'/></a>

fodo
02-29-2008, 12:39 PM
Thanks. Tried it and got an image box but no image. checked varaible has image reference and it does, so not finding the path i guess.
Tried a variation also (below) to no avail.
cant think of what to try next?


<a href="javascript:ajaxpage('<?php echo $p1?>', 'contentarea');"><img src="<?php echo "/images/".$book['pix']; ?>" border='0' width='80' height='100'/></a>

fodo
02-29-2008, 12:43 PM
Hi Nile. Added a . and it works.Many thanks for your help.Code below


<a href="javascript:ajaxpage('<?php echo $p1?>', 'contentarea');"><img src="<?php echo "./images/".$book['pix']; ?>" border='0' width='80' height='100'/></a>

Nile
02-29-2008, 01:10 PM
Your welcome!
;)