Jump to content

can't connect


xhelle

Recommended Posts

Hi to all,

 

I have this code in php that need to insert the data into database, the data came from xml files, the problem is during i run my code i receive an error. Can you please check my code where do i go wrong. Thanks in advance.

 

Here's my code:

$xml = simplexml_load_file("KtextContentCatcherSample.xml");

foreach ($xml->children() as $child) 
{
if ($child->getName() == 'params')
{
	foreach ($child->children() as $params) 
	{
		if ($params->getName() == 'ArtistName')
			$name = $params;

		if ($params->getName() == 'ServiceName')
			$sname = $params;

		if ($params->getName() == 'encoding')
			$encoding = $params;

		if ($params->getName() == 'Message')
			$message = $params;

		if ($params->getName() == 'Filename')
			$fname = $params;

		if ($params->getName() == 'Data')
			$data = base64_decode($params);

		$query = "SELECT * FROM inbox where artist_id = '";
	}
}
}

//write file
$file = '/var/www/ktext/public/images/content/' .$fname;
$fh = fopen($file, 'w') or die("Can't open file");
fwrite($fh, $data);
echo "Data Written";
fclose($fh);
echo $file;

//DATABASE CONFIGURATION
$DBhost = 'localhost';
$DBuser = 'root';
$DBpass = 'password';
$DBName = 'ktext';

$aname = $_POST['ArtistName'];
$amessage = $_POST['Message'];
$bmessage = $_POST['Message'];
$fname = $_POST['Filename'];

$conn = mysql_connect($DBhost, $DBuser, $DBpass) or die('Cannot connect to the database because: ' .mysql_error());
mysql_select_db($DBName) or die('Database not exist. ' .mysql_error());

$query = "INSERT INTO inbox ('id', 'artist_id', 'date_in, content', 'preview', 'picture') VALUES ('$aname', '$amessage', '$bmessage', '$fname')";

$result = mysql_query($query) or die('Error updating database');

echo "Database Updated";

 

Hope you can help me....

Link to comment
https://forums.phpfreaks.com/topic/162520-cant-connect/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.