Hello guys, my turn to ask a very simple question.
I already have a Mysql DB with querys working great.
I import data from Active Directory server, and one of the values is State, enabled or disabled, etc.
But this values came in a form of code:
512 = Enabled
514 = Disabled
544 = Enabled, Password Not Required
546 = Disabled, Password Not Required
66048 = Enabled, Password Doesnt Expire
66050 = Disabled, Password Doesn't Expire
66080 = Enabled, Password Doesn't Expire & Not Required
Now what i need is to insert the normal value in a new field
**Rude form:** If value is in row state is 512 insert into row state2 Enabled
Now i have the following code that is nor working:
<?php
// error_reporting(0);
// connect to the database
include('config_users.php');
$con = mysql_connect("$sqlhost","$sqluser","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
$sel = mysql_select_db($database, $con);
if (!$sel)
{
die('Could not select DB: ' . mysql_error());
}
$sql = 'SELECT * FROM users WHERE Estado = 66048';
$result = mysql_query($sql, $con);
if (!$result) {
echo "DB Error, could not query the database\n";
echo 'MySQL Error: ' . mysql_error();
exit;
}
while ($row = mysql_fetch_assoc($result)) {
mysql_query("INSERT INTO users (State2) values ('Enabled')");
}
mysql_free_result($result);
?>
What am i doing wrong?
The last 3 hours where spent looking for a solution...