Reputation: 2174
I am trying to get values of the enum into <option value="$enum">$enum</option>
but so far without any luck.
I cannot really say why, the error I get is "Catchable fatal error: Object of class PDOStatement could not be converted to string in C:\xampp\htdocs\sp-admin\form.php on line 58"
line 58 is $result = str_replace(array("enum('", "')", "''"), array('', '', "'"), $result);
and here is my php
$query = "SELECT column_type FROM information_schema.columns
WHERE table_name = 'files' AND column_name = 'cat_page_pos'";
$result = $db->prepare($query);
$result = str_replace(array("enum('", "')", "''"), array('', '', "'"), $result);
$arr = explode("','", $result);
return $arr;
please give me a hint here
thanks in advance
Upvotes: 0
Views: 1086
Reputation: 5605
Your $result
object is not the result you expect but the PDO statement to fetch result from.
try something like this after your call to $db->prepare
:
//perform SQL query on DB , since it has only be prepared
$result->execute();
//retrieve results from execution, here you obviously expect to get only one result
$data=$result->fetch();
$coltype=$data[0];
Then you'll find the string you want to process (with "enum('xxx','yyy')
" in the $coltype
variable)
Upvotes: 1