I have a frustrating experience in PHP because I keep getting my MEDIUMTEXT field returned as a non-string string. When I check the variable's type it says it's a string, but it's actually an array, basically a character array so I do:
while ($row = mysql_fetch_assoc($records)) {
print_r($row["myText"]);
}
Which instead of printing out the actual text stored there like "here is a line", it just prints 1. This is confusing because I ask it what it's datatype it and it says string... However if I do
$row["myText"][0]
It will return "h". I'm totally lost on how I can change this value into a string, I mean I would assume php has some function for it, but I can't find it. I also have no idea why it says it's not an array.
Any ideas?
edit by request
mysql query
select * from snippets
a print_r: text is the name of the MEDIUMTEXT column in mysql. The others aren't related
Array ( [index] => 1 [name] => a name [language] => english [text] => ) 1
edit2:
All the code that produced this error:
$username = "root";
$password = "";
$hostname = "localhost";
$dbname = "TestSnippets";
$dbh = mysql_connect($hostname, $username, $password)
$selected = mysql_select_db("snippets",$dbh);
$records = mysql_query("select * from snippets");
while ($row = mysql_fetch_assoc($records)) {
echo print_r($row);
}
This produces the error every time. All other fields come in perfectly fine. Not the MEDIUMTEXT field however.
edit3:
I tried installing a new webserver (Apache) and a new version of PHP, but it still has the same issue. Interestingly enough when I call php-cgi.exe it returns the data with that variable being output properly. I have zero clue what it could be, the only other this is I could install a different version of mysql. I'll try that tomorrow and report back.
edit4: I solved this myself keeping in mind what I was told here. See my answer to my own question below.