# Not able to access Wordpress data base

**URL:** <https://www.phphelp.com/t/not-able-to-access-wordpress-data-base/18210>\
**Category:** Help with WordPress\
**Created:** [September 3, 2012, 3:22pm UTC](https://www.phphelp.com/t/not-able-to-access-wordpress-data-base/18210 "2012-09-03T15:22:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kennonward](https://www.phphelp.com/letter_avatar_proxy/v4/letter/k/8baadc/32.png) [@kennonward](https://www.phphelp.com/u/kennonward)\
**Post date:** [September 3, 2012, 3:22pm UTC](https://www.phphelp.com/t/not-able-to-access-wordpress-data-base/18210/1 "2012-09-03T15:22:49Z")

</div>

Hi All:  
I was able to access Wordpress yesterday with the following code:

```auto
<html>
<head>
<script type="text/javascript">
function loadImage()
{
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","getuser_2.php",true);
xmlhttp.send();
alert("Image is loaded");
}
</script>
</head>
<body>
<div style="position: absolute; top:170px; left:340px; height:200px; width:200px;">

<img src="images/dk_green_box.jpg" onload="loadImage()" width="240" height="240" alt="" /> 
</div>

</body>
</html>
```

[php]

\<?php echo "
"; echo "
# Enter PHP for Data retrieval
"; echo "
"; // $q=$\_GET["q"]; // \*\* MySQL settings - You can get this info from your web host \*\* // /\*\* The name of the database for WordPress \*/ define('DB\_NAME', 'XXXXXX'); /\*\* MySQL database username \*/ define('DB\_USER', 'XXXXXX'); /\*\* MySQL database password \*/ define('DB\_PASSWORD', 'XXXXXX'); /\*\* MySQL hostname \*/ define('DB\_HOST', 'XXXXXX'); /\*\* Database Charset to use in creating database tables. \*/ define('DB\_CHARSET', 'utf8'); /\*\* The Database Collate type. Don't change this if in doubt. \*/ define('DB\_COLLATE', ''); $con = mysql\_connect(DB\_HOST, DB\_USER, DB\_PASSWORD); if (!$con) { die('Could not connect: ' . mysql\_error()); } else { echo('in the database'); } mysql\_select\_db( DB\_NAME, $con); $sql = "SELECT \* FROM wp\_posts where post\_title != 'Auto Draft' order by ID desc limit 0,1"; $result = mysql\_query($sql); if (!$result) { die('No data: ' . mysql\_error()); echo "
"; echo "
# Data failure
"; echo "
"; } else { echo "
"; echo "
# Data Success
"; echo "
"; echo "
"; echo ('BLOG'); echo ""; while($row = mysql\_fetch\_array($result)) { echo ""; echo ""; echo ""; echo ""; } echo "

 | Title | Content |
| --- | --- |
| " . $row['post\_title'] . " | " . substr($row['post\_content'],0,100) . " |

"; mysql\_close($con); } ?\>[/php]

Today I started adding in code to see why it was not working on a different page and it is now not working at all. Does anyone see anything I am missing? There are no errors or warnings. The echos are not working to let me know it is in the data base. The alert in the JAVA code works so I know I am getting that far.  
The strangest part is it was working yesterday and earlier today before I started adding in parts from a different page.
