NameSilo

PHP troubles with '

SpaceshipSpaceship
Watch

Kadenz

Resistance is FutileEstablished Member
Impact
29
I am having a problem with ' when it is submitted to PHP through a form, as it comes out as \' instead of '
I tired str_replace and stripcslashes commands and they don't seem to work, is there some way to fix this?
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
stripslashes
 
0
•••
if stripslashes isn't working you may have saved or resaved the data with the \' .

If that's the case you'd need to manually edit it if its a small number of records because stripslashes won't help you.
 
0
•••
code pls. usually an esc. character will do like / before the '
 
0
•••
' comes out like \' when submitted through a form if your server has magic_quotes_gpc turned on. For a solution that works on all servers:

if (get_magic_quotes_gpc()) {
$variable = stripslashes($variable);
}

This is of course assumes the programmer knows when to add slashes when needed.
For more information, please see the official PHP website:

http://us2.php.net/manual/en/function.get-magic-quotes-gpc.php
 
0
•••
Here is the code i'm using:
PHP:
<?php
if ($_GET[image] == "") {
    echo "Error: Invalid Entry, Please Choose a Template";
    } else {
if ($_GET[string] == "") {
    echo "Error: Invalid Entry, Please Insert Some Text";
    } else {
    if ($_GET[fontsize] != "") {
    $fsize = $_GET[fontsize];
    } elseif ($_GET[fontsize] == "") {
    $fsize = 16;
    }
    if ($_GET[fontsize2] != "") {
    $fsize2 = $_GET[fontsize2];
    } elseif ($_GET[fontsize2] == "") {
    $fsize2 = 16;
    }
    $myImage = ImageCreateFromPng("templates/".$_GET[image]);
    
    $grey = ImageColorAllocate($myImage, 128, 128, 128);
    $white = ImageColorAllocate($myImage, 255, 255, 255);
	$navy = ImageColorAllocate($myImage, 19, 19, 86);
	$bred = ImageColorAllocate($myImage, 199, 0, 0);
	$dred = ImageColorAllocate($myImage, 93, 11, 11);
	$black = ImageColorAllocate($myImage, 0, 0, 0);
	$string = stripcslashes($_GET[string]);
	$string2 = stripcslashes($_GET[string2]);
    if ($_GET[image] == "mu_bk2.png") {
    ImageTtfText($myImage, $_GET[fontsize], 0, 180, 34, $bred, "fonts/".$_GET[font], "$string");
    ImageTtfText($myImage, $_GET[fontsize2], 0, 220, 54, $bred, "fonts/".$_GET[font], "$string2");
    }
    elseif ($_GET[image] == "mu_all.png") {
    ImageTtfText($myImage, $_GET[fontsize] , 0, 100, 80, $navy, "fonts/".$_GET[font], "$string");
    ImageTtfText($myImage, $_GET[fontsize2], 0, 150, 110, $black, "fonts/".$_GET[font], "$string2");
    }
	elseif ($_GET[image] == "mu_bk.png") {
    ImageTtfText($myImage, $_GET[fontsize] , 0, 14, 80, $white, "fonts/".$_GET[font], "$string");
    ImageTtfText($myImage, $_GET[fontsize2], 0, 50, 100, $white, "fonts/".$_GET[font], "$string2");
    }
	elseif ($_GET[image] == "mu_dl.png") {
    ImageTtfText($myImage, $_GET[fontsize] , 0, 40, 80, $dred, "fonts/".$_GET[font], "$string");
    ImageTtfText($myImage, $_GET[fontsize2], 0, 60, 100, $dred, "fonts/".$_GET[font], "$string2");
    }
	elseif ($_GET[image] == "mu_mg.png") {
    ImageTtfText($myImage, $_GET[fontsize] , 0, 160, 40, $white, "fonts/".$_GET[font], "$string");
    ImageTtfText($myImage, $_GET[fontsize2], 0, 200, 60, $white, "fonts/".$_GET[font], "$string2");
    } else {
    ImageTtfText($myImage, $_GET[fontsize], 0, 200, 80, $white, "fonts/".$_GET[font], "$string");
    ImageTtfText($myImage, $_GET[fontsize2], 0, 200, 100, $white, "fonts/".$_GET[font], "$string2");
    }
    header ("Content-type: image/png");
    ImagePNG($myImage);
    ImageDestroy($myImage);
    }}
?>
 
0
•••
PHP:
<?php
$image = stripslashes($_GET[image]);
$string = stripslashes($_GET[string]);
$string2 = stripslashes($_GET[string2]);
$font = stripslashes($_GET[font]);
$fontsize = stripslashes($_GET[fontsize]);
$fontsize2 = stripslashes($_GET[fontsize2]);

if ($image == "") {
    echo "Error: Invalid Entry, Please Choose a Template";
} else {
	if ($string == "") {
	    echo "Error: Invalid Entry, Please Insert Some Text";
	} else {
		if ($fontsize != "") {
	    	$fsize = $fontsize;
	    } elseif ($fontsize == "") {
    		$fsize = 16;
    	}
    	if ($fontsize2 != "") {
    		$fsize2 = $fontsize2;
    	} elseif ($fontsize2 == "") {
    		$fsize2 = 16;
    	}

    	$myImage = ImageCreateFromPng("templates/".$image);
    
		$grey = ImageColorAllocate($myImage, 128, 128, 128);
    	$white = ImageColorAllocate($myImage, 255, 255, 255);
		$navy = ImageColorAllocate($myImage, 19, 19, 86);
		$bred = ImageColorAllocate($myImage, 199, 0, 0);
		$dred = ImageColorAllocate($myImage, 93, 11, 11);
		$black = ImageColorAllocate($myImage, 0, 0, 0);
		$string = stripcslashes($string);
		$string2 = stripcslashes($string2);
    	if ($image == "mu_bk2.png") {
    		ImageTtfText($myImage, $fontsize, 0, 180, 34, $bred, "fonts/".$font, "$string");
    		ImageTtfText($myImage, $fontsize2, 0, 220, 54, $bred, "fonts/".$font, "$string2");
    	} elseif ($image == "mu_all.png") {
    		ImageTtfText($myImage, $fontsize , 0, 100, 80, $navy, "fonts/".$font, "$string");
    		ImageTtfText($myImage, $fontsize2, 0, 150, 110, $black, "fonts/".$font, "$string2");
    	} elseif ($image == "mu_bk.png") {
    		ImageTtfText($myImage, $fontsize , 0, 14, 80, $white, "fonts/".$font, "$string");
    		ImageTtfText($myImage, $fontsize2, 0, 50, 100, $white, "fonts/".$font, "$string2");
    	} elseif ($image == "mu_dl.png") {
    		ImageTtfText($myImage, $fontsize , 0, 40, 80, $dred, "fonts/".$font, "$string");
    		ImageTtfText($myImage, $fontsize2, 0, 60, 100, $dred, "fonts/".$font, "$string2");
    	} elseif ($image == "mu_mg.png") {
    		ImageTtfText($myImage, $fontsize , 0, 160, 40, $white, "fonts/".$font, "$string");
    		ImageTtfText($myImage, $fontsize2$font, 0, 200, 60, $white, "fonts/".$font, "$string2");
    	} else {
    		ImageTtfText($myImage, $fontsize$fontsize2, 0, 200, 80, $white, "fonts/".$font, "$string");
    		ImageTtfText($myImage, $fontsize2, 0, 200, 100, $white, "fonts/".$font, "$string2");
    	}
    	header ("Content-type: image/png");
    	ImagePNG($myImage);
    	ImageDestroy($myImage);
    }
}
?>
 
0
•••
Fixed it, it actually wasn't in that file, sorry for all of the trouble.
 
0
•••
Dynadot — .com TransferDynadot — .com Transfer
Appraise.net

We're social

Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
DomDB
NameFit
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back