?
Solved

string won't store in mysql db

Posted on 2005-05-04
7
Medium Priority
?
236 Views
Last Modified: 2010-04-06
i'm busy working on another portion of a program; no time to diagnose this.
can someone tell me why this string isn't getting stored into my mysql table?  (this is all on one line also)..no returns or anything.

<script language='JavaScript' type='text/javascript' src='http://www.xxxx.com/ads/adx.js'></script><script language='JavaScript' type='text/javascript'>   if (!document.phpAds_used) document.phpAds_used = ',';   phpAds_random = new String (Math.random()); phpAds_random = phpAds_random.substring(2,11);      document.write (\"<\" + \"script language='JavaScript' type='text/javascript' src='\");   document.write (\"http://www.xxxx.com/ads/adjs.php?n=\" + phpAds_random);   document.write (\"&amp;what=zone:1\");   document.write (\"&amp;exclude=\" + document.phpAds_used);   if (document.referrer)      document.write (\"&amp;referer=\" + escape(document.referrer));   document.write (\"'><\" + \"/script>\");</script><noscript><a href='http://www.xxxx.com/ads/adclick.php?n=a0bcce5f' target='_blank'><img src='http://www.xxxx.com/ads/adview.php?what=zone:1&n=a0bcce5f' border='0' alt=''></a></noscript>

0
Comment
Question by:linuxrox
  • 4
  • 3
7 Comments
 
LVL 16

Expert Comment

by:alain34
ID: 13927980
could you post the complete script including the sql statement!
0
 

Author Comment

by:linuxrox
ID: 13928057
this is the actual string that should get stored into the db:
<!-- web2printer:start -->hello there, this is an example of a story. A banner should follow right NOW:<!--start--><script language='JavaScript' type='text/javascript' src='http://www.k105.com/ads/adx.js'></script><script language='JavaScript' type='text/javascript'>   if (!document.phpAds_used) document.phpAds_used = ',';   phpAds_random = new String (Math.random()); phpAds_random = phpAds_random.substring(2,11);      document.write ("<" + "script language='JavaScript' type='text/javascript' src='");   document.write ("http://www.k105.com/ads/adjs.php?n=" + phpAds_random);   document.write ("&amp;what=zone:1");   document.write ("&amp;exclude=" + document.phpAds_used);   if (document.referrer)      document.write ("&amp;referer=" + escape(document.referrer));   document.write ("'><" + "/script>");</script><noscript><a href='http://www.k105.com/ads/adclick.php?n=a0bcce5f' target='_blank'><img src='http://www.k105.com/ads/adview.php?what=zone:1&n=a0bcce5f' border='0' alt=''></a></noscript><!--end-->And this is the last half of the story.<!-- web2printer:end -->


here is the portion of the script i'm working with:
(also, everything displays fine i know because if i exit the program before the string is to be placed into the database and echo it to the browser, it displays just fine....it is failing when entering the string into the database)  perhaps it's the $storynohtml that is crapping it out.

$story = eregi_replace("[\r\n]",'', addslashes($data));
        $story = "<!-- web2printer:start -->".$story."<!-- web2printer:end -->";
###############START BANNER CODE#################      
             $array = array('<!--start-->','<!--start2-->','<!--start3-->');
            $num = count($array);
            for ($x=0; $x<=$num; $x++){
            if (stristr($story, $array[$x])){
            $commentstart = $array[$x];
            }
            }
            $banner = "<script language='JavaScript' type='text/javascript' src='http://www.xxxx.com/ads/adx.js'></script><script language='JavaScript' type='text/javascript'>   if (!document.phpAds_used) document.phpAds_used = ',';   phpAds_random = new String (Math.random()); phpAds_random = phpAds_random.substring(2,11);      document.write (\"<\" + \"script language='JavaScript' type='text/javascript' src='\");   document.write (\"http://www.xxxx.com/ads/adjs.php?n=\" + phpAds_random);   document.write (\"&amp;what=zone:1\");   document.write (\"&amp;exclude=\" + document.phpAds_used);   if (document.referrer)      document.write (\"&amp;referer=\" + escape(document.referrer));   document.write (\"'><\" + \"/script>\");</script><noscript><a href='http://www.xxxx.com/ads/adclick.php?n=a0bcce5f' target='_blank'><img src='http://www.xxxx.com/ads/adview.php?what=zone:1&n=a0bcce5f' border='0' alt=''></a></noscript>";
            
            $banner2 = "<script language='JavaScript' type='text/javascript' src='http://www.k105.com/ads/adx.js'></script><script language='JavaScript' type='text/javascript'>   if (!document.phpAds_used) document.phpAds_used = ',';   phpAds_random = new String (Math.random()); phpAds_random = phpAds_random.substring(2,11);      document.write (\"<\" + \"script language='JavaScript' type='text/javascript' src='\");   document.write (\"http://www.k105.com/ads/adjs.php?n=\" + phpAds_random);   document.write (\"&amp;what=zone:3\");   document.write (\"&amp;exclude=\" + document.phpAds_used);   if (document.referrer)      document.write (\"&amp;referer=\" + escape(document.referrer));   document.write (\"'><\" + \"/script>\");</script><noscript><a href='http://www.k105.com/ads/adclick.php?n=aed4b9df' target='_blank'><img src='http://www.k105.com/ads/adview.php?what=zone:3&n=aed4b9df' border='0' alt=''></a></noscript>";
            $banner3 = "<script language='JavaScript' type='text/javascript' src='http://www.k105.com/ads/adx.js'></script><script language='JavaScript' type='text/javascript'>   if (!document.phpAds_used) document.phpAds_used = ',';   phpAds_random = new String (Math.random()); phpAds_random = phpAds_random.substring(2,11);      document.write (\"<\" + \"script language='JavaScript' type='text/javascript' src='\");   document.write (\"http://www.k105.com/ads/adjs.php?n=\" + phpAds_random);   document.write (\"&amp;what=zone:2\");   document.write (\"&amp;exclude=\" + document.phpAds_used);   if (document.referrer)      document.write (\"&amp;referer=\" + escape(document.referrer));   document.write (\"'><\" + \"/script>\");</script><noscript><a href='http://www.k105.com/ads/adclick.php?n=aed4b9df' target='_blank'><img src='http://www.k105.com/ads/adview.php?what=zone:2&n=aed4b9df' border='0' alt=''></a></noscript>";
        if ($commentstart=="<!--start-->"){
            $bannerfinal = $banner;
            }elseif($commentstart=="<!--start2-->"){
            $bannerfinal = $banner2;
            }elseif($commentstart=="<!--start3-->"){
            $bannerfinal = $banner3;
            }
            $startlen = strlen($commentstart);
            $end = "<!--end-->";
            $endlen = strlen($end);
            $start= strpos($story, "$commentstart");
            $finish= strpos($story, "$end");
            $length= $finish-$start;
            $storyfirsthalf=substr($story, 0, $start);
            $storylasthalf=substr($story, $finish+$endlen);
            $story = $storyfirsthalf.$commentstart.$bannerfinal.$end.$storylasthalf;
            //echo $story;
            //exit;
###############END BANNER CODE#################
        $storynohtml = strip_tags($story);
        $skeyword = $_POST['keywords'];
            $sclip = $_POST['audioclip'];
            $pday = $_POST['day'];
            $author = $_POST['byname'];
            $organization = $_POST['organization'];
            $email = $_POST['email'];
            $relatedid = $_POST['relatedid'];
            $link1 = addslashes($_POST['link1']);
            $link2 = addslashes($_POST['link2']);
            $link3 = addslashes($_POST['link3']);
            $priority = $_POST['priority'];
            $pmonth = $_POST['month'];
            $pyear = $_POST['year'];
            $today = date("Y-m-d");
            $fdate = $pyear."-".$pmonth."-".$pday;
            
        $cat = $_POST['scats'];
        $title = addslashes($_POST['stitle']);
 
            $insert=mysql_db_query($dname,"INSERT INTO paths (id, relatedid, priority, relatedlink1, relatedlink2, relatedlink3, authorname, authoremail, organization, storydate, title, keyword, audioclip, webstory, datewritten, webstorynohtml) VALUES (NULL, '$relatedid','$priority','$link1','$link2','$link3','$author','$email','$organization','$fdate','$title','$skeyword','$sclip','$story','$today','$storynohtml')");
       
        foreach ($cat as $key => $value )
        $insert=mysql_db_query($dname,"INSERT INTO category (category, id) VALUES ('$value',LAST_INSERT_ID())");  
0
 

Author Comment

by:linuxrox
ID: 13928154
I figured it out...merely addslashes($banner) solved it after i commented out  //$storynohtml = strip_tags($story);
now i should just have to do the same to storynohtml
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 16

Accepted Solution

by:
alain34 earned 2000 total points
ID: 13928179
you are right. strip_tags remove all tags, including <script> and so on.
therefore after that, nothing was left to be stored!
0
 

Author Comment

by:linuxrox
ID: 13928204
Lemme give you these points :)
0
 

Author Comment

by:linuxrox
ID: 13928213
wish i could edit out my domainname in this question but i guess i cannot.
0
 
LVL 16

Expert Comment

by:alain34
ID: 13930481
post a question in community support to request the editing of the question and remove your domain name!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question