[Solved] Using PHP to check a MySQL field exists
Posted: Mon Nov 28, 2005 7:06 am
Wasn't sure whether I should have put this here or in Databases, but hey ho.
I want to use PHP to see if a field exists in a table (and if it doesn't, I'll add it).
I've got
But that doesn't work 
I want to use PHP to see if a field exists in a table (and if it doesn't, I'll add it).
I've got
Code: Select all
$row = mysql_fetch_row("SELECT count(field_name) from user");
if (!$row)
{
$sql = "ALTER TABLE user ADD field_name TEXT NOT NULL";
}