?
Solved

Removing the ' and " marks

Posted on 2004-04-23
8
Medium Priority
?
196 Views
Last Modified: 2010-04-06
Hi all,

     I want to store some html/php/javascript in a mySQL database field i.e.

<html>
<p>
<?php echo "hello" ?>
</p>
</html>


and then extract this information and echo it via a php script. i.e.

//conect to db

$info = mysql_query("select * from script where script_id = $script_id", $db);

//if entry exists

echo "$info";


The problem is that the script contains "speech marks" and ultimately ends the echo " " function to early. Any ideas?

-Thanks Chris.
0
Comment
Question by:icb01co2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 6

Accepted Solution

by:
jkna_gunn earned 220 total points
ID: 10898177
0
 
LVL 6

Expert Comment

by:Lord_McFly
ID: 10898692
Before performing the insert do something like..

mysql_query = Replace(mysqlquery,Chr(34),"[quote]")

..then do you insert / update

The just do the reverse Replace when you extract..

myString = Replace(rs("FieldName"),"[quote]",Chr(34))

I can't remember the Chr() num,ber for quotes so just check that out.
0
 
LVL 6

Expert Comment

by:Lord_McFly
ID: 10946127
I was just going over my posts again and realised my suggestion wasn't relavent as you're using php :)

I'm guessing that you are getting a prepared php scripted and just want to display it with your webpage - I think the following might work - replace " with the HTML equiv.

$info = str_replace(chr(34),'&quot;',$info)
0
 
LVL 8

Expert Comment

by:hendridm
ID: 10959422
Why not remove the quotes around $info like so:
echo $info;

Not sure why having quotes around it should break it though.  Also, beware of SQL injection in your select statement:

if(is_numeric($script_id)) {
   $info = mysql_query("select * from script where script_id = $script_id", $db);
}
0
 

Expert Comment

by:zeroisawuss
ID: 11008517
$data = addslashes($data)

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

801 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