wordpress

how to access DB at wordpress

 

$city=””;

$address=””;

$postcode=””;

$phone=””;

$wpconfig = get_site_url().”/wp-config.php”;

foreach (explode(“n”, file_get_contents($wpconfig)) as $line)

{

if (preg_match(‘/define.+?DB_|table_prefix/’, $line))

eval($line);

}

 

if (defined(‘DB_USER’))

{

$dbh = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);

mysql_select_db(DB_NAME, $dbh);

 

$sqlq=”select * from wp_cimy_uef_data where user_id='”.$curr_user->id.”‘” ;

 

 

$r = mysql_query( $sqlq,$dbh) or die(mysql_error());

while($userdata = mysql_fetch_array($r)){

// print_r($userdata);

 

if($userdata[FIELD_ID]==1)

$address=$userdata[VALUE];

if($userdata[FIELD_ID]==2)

$city=$userdata[VALUE];

if($userdata[FIELD_ID]==3)

$postcode=$userdata[VALUE];

if($userdata[FIELD_ID]==4)

$phone=$userdata[VALUE];

 

}

 

}

 

 

Advertisements