[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now


Removing the ' and " marks

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

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

<?php echo "hello" ?>

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.
Question by:icb01co2
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

Accepted Solution

jkna_gunn earned 220 total points
ID: 10898177

Expert Comment

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.

Expert Comment

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)

Expert Comment

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);

Expert Comment

ID: 11008517
$data = addslashes($data)


Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

It's sometimes a bit tricky to use date functions in Oracle BPEL. I'll explain quickly how you can add N days to the current date. In a BPEL process this can be useful, and you can adapt it to fit your needs. First of all, let's see how to add 1 …
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
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

650 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