Skip to main content

mysql row turning into attributes



I need help with an <input> . Some times when I call for the var to be inserted into the value="" part of the <input> it makes every word into an attribute. For example my tag will look like this <input type="hidden" name="article" this="" is="" the="" article="" text="" />





and the call to the <input> is this echo '<input type="hidden" name="article" value="'.$row['article'].'" />';





below is the actual code





CODE:







echo '<input type="hidden" name="date_added" value="'.$row['date_added'].'" />';

echo '<input type="hidden" name="id" value="'.$row['id'].'" />';

echo '<input type="hidden" name="article" value="'.$row['article'].'" />';

echo '<input type="hidden" name="pub_date" value="'.$row['pub_date'].'" />';







OUTPUT:







<input type="hidden" "="" added.="" snow,"="" shoveling="" those="" times,="" four="" years="" two="" real="" worn="" only="" "i've="" balance."="" i'm="" feels,="" actual="" where="" point="" gotten="" i've="" shoes.="" thing,"="" different="" whole="" ground,="" can="" "when="" world."="" senses="" off="" closing="" disconnected.="" time.="" all="" gloves="" wearing="" likens="" feeling."="" addicting="" an="" almost="" it's="" you,="" around="" world="" feeling="" used="" "you="" them,"="" comfortable="" you're="" wear="" choosing="" more="" "it's="" feet.="" your="" feel="" lifestyle"="" "barefoot="" calls="" being="" enjoys="" things="" explained="" experience."="" textures="" many="" "there's="" greatest,"="" "chautauqua="" chautauqua,="" trailhead="" favorite="" group's="" boulder="" aurora="" members="" year-round="" hikes="" day?"="" my="" rest="" what="" well,="" at,="" look="" have="" you="" that,="" explore="" start="" "but="" society,"="" prolific="" because="" thing,="" now="" attention="" people's="" grabbing="" what's="" members,="" 100="" surpassed="" recently="" grown="" has="" their="" it?="" why="" thought,="" hiking,="" enjoyed="" since="" home,="" clients="" works="" she's="" day="" spending="" already="" brushaber="" group.="" join="" first="" who="" practitioner="" movement="" brushaber,="" kriste="" organizing="" partner="" hartman's="" hiking.="" eventually,="" walking="" kept="" marathon,="" run="" change.="" change."="" would="" pain.="" back="" time,="" at="" marathon="" training="" problems.="" other="" few="" splints="" shin="" hartman="" ago,"="" while="" running.="" trying="" after="" started="" group="" meetup="" range="" front="" hartman,="" mary="" thing."="" natural,="" this="" into="" getting="" are="" "people="" he="" (shoes),"="" our="" trail="" appalachian="" guys="" "we="" sashen="" somewhere,"="" some="" top="" them="" me="" showing="" people="" from="" pictures="" testimonials="" get="" walking.="" nearly-barefoot="" for="" footwear="" sandals="" vibram-soled="" light="" makes="" which="" shoes,="" invisible="" founder="" sashen,="" steven="" says="" deal,="" big="" becoming="" minimalist="" boom.="" running="" heels="" on="" popularity="" in="" growing="" shoes="" without="" hiking="" say="" barefooters="" local="" most,="" loftier="" bit="" ascent="" barefoot="" baker's="" said.="" could="" knew="" so="" kilimanjaro,="" than="" harder="" lot="" hell="" "longs="" crazy.="" baker="" but="" crazy."="" quite="" is="" climbing="" everyone="" about="" just="" "i="" said,="" barefoot,="" kili="" climb="" try="" crazy="" it="" thought="" would've="" guides="" whether="" asked="" before.="" that="" like="" request="" a="" made="" ever="" had="" one="" no="" though="" even="" sure,="" paschall="" barefoot.="" attempt="" she'd="" sure="" make="" reach,="" within="" adventures="" boulder's="" owner="" paschall,="" robin="" agent,="" travel="" her="" with="" checked="" year,="" last="" peak="" highest="" africa's="" --="" mountain="" 19,336-foot="" trip="" the="" booked="" she="" when="" boulder.="" of="" baker,="" said="" it,"="" welcoming="" really="" not="" were="" and="" it,="" do="" able="" be="" to="" going="" was="" i="" think="" didn't="" they="" value="When Sonnet Baker showed up at the bottom of Mount Kilimanjaro ready to hike up the mountain barefoot, her guides had doubts. " name="article">







All the others <input> fields work fine. Please tell me what I'm doing wrong.


Comments

  1. Always use htmlspecialchars($string, ENT_QUOTES) when putting data in HTML-attributes:

    echo '<input type="hidden" name="article" value="'.htmlspecialchars($row['article'], ENT_QUOTES).'" />';


    Also, google for XSS-attacks.

    ReplyDelete

Post a Comment

Popular posts from this blog

Why is this Javascript much *slower* than its jQuery equivalent?

I have a HTML list of about 500 items and a "filter" box above it. I started by using jQuery to filter the list when I typed a letter (timing code added later): $('#filter').keyup( function() { var jqStart = (new Date).getTime(); var search = $(this).val().toLowerCase(); var $list = $('ul.ablist > li'); $list.each( function() { if ( $(this).text().toLowerCase().indexOf(search) === -1 ) $(this).hide(); else $(this).show(); } ); console.log('Time: ' + ((new Date).getTime() - jqStart)); } ); However, there was a couple of seconds delay after typing each letter (particularly the first letter). So I thought it may be slightly quicker if I used plain Javascript (I read recently that jQuery's each function is particularly slow). Here's my JS equivalent: document.getElementById('filter').addEventListener( 'keyup', function () { var jsStart = (new Date).getTime()...

Is it possible to have IF statement in an Echo statement in PHP

Thanks in advance. I did look at the other questions/answers that were similar and didn't find exactly what I was looking for. I'm trying to do this, am I on the right path? echo " <div id='tabs-".$match."'> <textarea id='".$match."' name='".$match."'>". if ($COLUMN_NAME === $match) { echo $FIELD_WITH_COLUMN_NAME; } else { } ."</textarea> <script type='text/javascript'> CKEDITOR.replace( '".$match."' ); </script> </div>"; I am getting the following error message in the browser: Parse error: syntax error, unexpected T_IF Please let me know if this is the right way to go about nesting an IF statement inside an echo. Thank you.