Can you guys find anything wrong with this php code? I always get the “Error: Could not show columns” message, but when I try the query “show columns from recipes like ‘Book'” in the MySQL Command Line Client it works just fine.
I got this code snippet from one of the comments in the section on Sets in the MySQL Reference Manual. It’s supposed to get all possible values of a Set and store them in an array.
<?php
$query = "SHOW COLUMNS FROM recipes LIKE 'Book'";
if (!($ret = mysql_query($query)))
die("Error: Could not show columns");
$line = mysql_fetch_assoc($ret);
$set = $line['Type'];
$set = substr($set,5,strlen($set)-7);
$options = preg_split("/','/",$set);
?>
Perhaps there is another way to accomplish this?
Looks like you haven’t selected a database using
mysql_select_db.Try changing your
diestatement to:Make sure to remove this before moving your code to production.