Hi I am experienced in ASP w/ C# but a beginner in PHP:

How do I get the value of a unique index of a column of mySQL in PHP:

try{
//do connect
//insert data
}
catch(Exception ex){
 if (ex.Message.IndexOf("Column_Name") >= 0) //<-- how do I do this in PHP?
     error = "That Column_Name already exists. Please change the Column_Name.";
}

Recommended Answers

All 2 Replies

how do u mean u could just say

mysql_connect("host", "username", "pass");
mysql_select_db("db_name");
$your_name = "2";
$query "SELECT * FROM table_name WHERE collum_name = '$your_number'";
$result = mysql_query($query);
if(mysql_numrows($result) >= 1)
{
echo "That Column_Name already exists. Please change the Column_Name.";
}
$your_name = "2";
$query "SELECT * FROM table_name WHERE collum_name = '$your_name'";
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.