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
https://forums.phpfreaks.com/topic/224152-quote-marks/
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
https://forums.phpfreaks.com/topic/224152-quote-marks/#findComment-1158243
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
https://forums.phpfreaks.com/topic/224152-quote-marks/#findComment-1158245
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.