geebo Posted August 23, 2008 Share Posted August 23, 2008 I am using a MySQL DB to store text. I am using php to echo the text onto a web page. My apostrophes come out as question marks: "Washington's" = "Washington?s". I a php newbie, but tried to be a good boy and search for a fix before asking for help. From what I read, mysql_escape_string is the fix I'm looking for. Dreamweaver inserted mysql_escape_string code when writing my query, but obviously something's not quite right. Isn't the following code telling MySQL to handle a ' as a ' ? THANK YOU! Dreamweaver inserted the following code: if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } Link to comment https://forums.phpfreaks.com/topic/121001-mysql-escape-string-help/ Share on other sites More sharing options...
BlueSkyIS Posted August 23, 2008 Share Posted August 23, 2008 the problem may not be an actual single quote, but a 'smart quote' if you copy/paste from MS Word or some other applications. Link to comment https://forums.phpfreaks.com/topic/121001-mysql-escape-string-help/#findComment-623765 Share on other sites More sharing options...
geebo Posted August 23, 2008 Author Share Posted August 23, 2008 the problem may not be an actual single quote, but a 'smart quote' if you copy/paste from MS Word or some other applications. I do import the data from an Excel spreadsheet, but saved as a .csv file. Isn't that text only? Link to comment https://forums.phpfreaks.com/topic/121001-mysql-escape-string-help/#findComment-623769 Share on other sites More sharing options...
BlueSkyIS Posted August 23, 2008 Share Posted August 23, 2008 not necessarily. Link to comment https://forums.phpfreaks.com/topic/121001-mysql-escape-string-help/#findComment-623773 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.