i have an echo statement. which am looping columns. and i want to use this onerror command
<img src="http://subinsb.com/to-an-image" onerror="this.src='img/delogo.jpg';"/>
but not working. how do i do this. thanks

  echo '  <div class="col-lg-5 col-md-5 col-xs-12">
                            <h4 class="font_head_check">' . $title . '<span class="box_type_unik">For Sale</span></h4>
                            <p class="font_check">' . $town . '</p>
                            <span class="label label-info">GH¢ ' . ($currency == 2 ? number_format($price * $ratio) : number_format($price)) . '</span>
                            <span class="label label-default"></span>
                            <p class="agent_det_unika"><br/>' . substr($description, 0, 400) . '</p>

                        </div>
                        <div class="vertical-line" style=""></div>
                        <div class="col-lg-2 col-md-2 col-xs-12 col_comp_img">

                            "<img src="'.$logo.'" class="img-responsive result_comp_logo" onerror="this.src='img/delogo.jpg';">


                            <br/>
                            <p class="font_unik_comp" style="display:none;">Sunda Estates</p>
                            <p class="num_unika_size">' . $phone . '</p>
                        </div>
                    </div>';

i can get it working in normal html but fixing it in the php echo statement is my issue.Thanks

Member Avatar for diafol

Placing all that HTML into a PHP string is just insane. Why on earth are you doing this? Anyway, your funeral...

onerror="this.src='img/delogo.jpg';"

If you have to have those single quotes in the string, then you must escape them as your using a single quoted string in PHP:

onerror="this.src=\'img/delogo.jpg\';"
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.