$currentFile = $_SERVER["SCRIPT_NAME"];
$img = array_pop(explode("/", $currentFile));
$fileName = basename($img, ".php").PHP_EOL;
echo $fileName;
Echo’d results:
placementName
$query = "SELECT * FROM image_Name WHERE name = '" . mysql_real_escape_string($fileName) . "' LIMIT 1;";
echo $query;
Echo’d results:
SELECT * FROM image_name WHERE name = ‘placementName\r\n’ LIMIT 1;
I’m trying to get a dynamic page to change its values in tables depending on what currentFile.php is open. Hence the script at the top. Script finds the fileName by chopping off the location and the ext and leaves the actual basename. Then the query looks for that basename in my database table, saves that data into an array which I want to be able to call for it to put it into a html table.
The problem right now is, my query for some reason has extra values appended to placementName “\r\n”
why is this ?
.PHP_EOL is appending these characters to the end of your string. You see them in your second output because of the mysql_real_escape.