Jump to content

Can't Query MySQL Database and Get it to Write to an XML File


Akenatehm

Recommended Posts

Hey Guys,

 

I am trying to set a script up that will read the information from one of my tables and display it in an xml file. Here is my code. Any help would be enormously appreciated.

 

Thanks

Aken

<?PHP

$link = mysql_connect("localhost","username","password");
mysql_select_db("kaurlcom_messenger");

$query = 'SELECT * FROM users'; 
$results = mysql_query ($query);

echo "<?xml version=\"1.0\"?>\n";
echo "<users>\n";

while ($line = mysql_fetch_assoc($results)) {
echo "<username>" . $line["username"] . "</username>\n";
}

echo "</users>\n";

mysql_close($link);

?>

 

 

It would be enormously helpful if you told us what it was or was not doing? What do you see in front of you when you try it?

 

Here are some possibilities -

 

Php is not installed and working.

Mysql is not installed and working.

The mysql extension in php is not installed and working.

The mysql_connect is failing because of wrong database credentials.

The msyql_select_db is failing because of a wrong database name.

The code is generating a syntax error.

The mysql_query is failing because of a wrong table name.

The <?xml tag is not causing the output in the browser to be formatted as xml.

There are no rows in the database.

 

Just posting code and stating or implying that it does not work is pointless. Narrow the problem down for us please.

 

Hey. I am very sorry for not being as specific as I could be. Whenever i try and browse to the php file e.g. www.url.com/file.php it says page cannot be found. I just spoke with a friend and he said it was because I don't have an index.php file. I don't know exactly what to put in that file.

 

My friend and I are trying to create an Instant Messaging Client with Flash. We want this PHP file to get users from the database and post the information into an XML file which will be accessed via Action SCript.

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.