You are here: Re: can't insert javascript call with PHP « PHP Programming Language « IT news, forums, messages
Re: can't insert javascript call with PHP

Posted by Rik on 07/23/07 18:02

On Mon, 23 Jul 2007 19:43:19 +0200, <rynato@gmail.com> wrote:

> here is the PHP function:
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> function image($src,$width,$height,$alt=3Dnull,$title=3Dnull,$class=3D=
null,
> $id=3Dnull,$name=3Dnull,$js=3Dnull) {
> }
> =3D=3D=3D=3D=3D=3D=3D=3D
>
> as you can see, any javascript is appended to the end of the tag, then=

> it gets closed with />
>
> here is the bit of code which called the function:
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> $query =3D "SELECT src,width,height,alt,title,class,id,name FROM img
> WHERE fid =3D '$fid'";
> $result =3D mysql_query($query);
> $loop =3D mysql_num_rows($result);
> for ($i=3D0;$i<$loop;$i++) {
> $a_row =3D mysql_fetch_row($result);
> $img[$i] =3D image($a_row[0],$a_row[1],$a_row[2],$a_row[3],$a_row[4]=
,
> $a_row[5],$a_row[6],$a_row[7],$a_row[8]);


how about:
for(...){
$a_row =3D mysql_fetch_row($result);
if($i=3D=3D0) $a_row[9] =3D ' onLoad=3D"preloadImages();" ';
$img[$i] =3D call_user_func_array('image',$a_row);
}

<SNIP EXAMPLE>
> same result as if it had retrieved the js from the table - it comes
> out as <img src=3D"foo" title=3D"foo" onLoad=3D"
>
> just chokes at the quote...

As you put it, doesn't choke at the quote but _after_ the quote... Can't=
=

reproduce it here, weird. Are there any other filters in action? Maybe i=
f =

you echo the result of yout image() function then and there...
-- =

Rik Wasmus

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация