Jump to content

Quote marks


icekat83

Recommended Posts

Hey,

 

I have a variable: 151°06'50"E

 

This variable is giving me massive problems because of the single and double quote marks. PLEASE help me get rid of my damn t_string error!

 

$var = 151°06'50"E;            - does not work

$var2 = (151°06'50"E);            - does not work

$var3 = ("151°06'50"E");            - does not work

$var4 = ('151°06'50"E');            - does not work

$var5 = addslashes("151°06'50"E");            - does not work

$var6 = addslashes('151°06'50"E');            - does not work

$var7 = mysql_escape_string("151°06'50"E");            - does not work

$var8 = mysql_escape_string('151°06'50"E');            - does not work

$var9 = htmlspecialchars("151°06'50"E");            - does not work

$var10 = htmlspecialchars('151°06'50"E');            - does not work

$var11 = urlencode("151°06'50"E");            - does not work

$var12 = urlencode('151°06'50"E');            - does not work

 

I've also tried the three functions with the various enclosing quote marks (single and double). I've also tried string replace.

 

At the moment I'll settle for being able to put:

 

echo $var;

 

and NOT have an error. Please help...this error is driving me nuts!!!

 

 

IceKat.

 

Link to comment
Share on other sites

t_string error

 

That's a php parse error because your data string contains quotes that break the php string syntax. For typing that data literally into your php code, whatever overall start/end quote type is being used, must be escaped when it occurs inside of the string. The following two variations work -

<?php
$var = "151°06'50\"E";
echo $var;

$var4 = '151°06\'50"E'; 
echo $var4;
?>

Link to comment
Share on other sites

You would need to be more specific about where you are getting the data from and where you are using the data.

 

We only see the information you supply in your post and for the error message you hinted at, that can only occur when you have the value literally entered in a php statement. When that value comes from a form or reading some data into a variable, you won't be getting php parse errors.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.