Page 1 of 1

I need some help with PHP (i'm kind of newbie)

Posted: Mon Mar 24, 2008 10:27 am
by skinnycat
<?php
$con = mysql_connect("localhost","user","pwr");
mysql_select_db("radiobor_radio", $con);

$query = 'SELECT songs.url_song as url_song,artist.description as artist,songs.description as description,songs.url_art_song as url_art FROM songs,artist where songs.artist_id = artist.artist_id ';
$result = mysql_query($query);

echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
echo "<xsongs>\n";

while ( $row = mysql_fetch_assoc($result) )
{
echo "<xsong" . " surl=\"" . $row["url_song"] . "\" " . "sartist=\"" . $row["artist"] . "\" " . "strack=\"" . $row["description"] . "\" " . "sart=\"" . $row["url_art"] . "\" " . "/>\n";
}
mysql_close($con);
echo "</xsongs>\n";
-------------------------------------------------------------------------------

This PHP script generates a XML file by selecting a mysql database. When I upload this script into my server it works perfectly but when I try to test it on my computer a get the following result:

\n"; echo "\n"; while ( $row = mysql_fetch_assoc($result) ) { echo "\n"; } mysql_close($con);
echo "\n"; ?>

I'm using Uniform Server to manage Apache and mysql. I think I got something to do with setting or stuff, but I'm not sure. It is like Internet Explorer does not recognize php.

Re: I need some help with PHP (i'm kind of newbie)

Posted: Mon Mar 24, 2008 10:36 am
by Resco
You're sure you got PHP running on your local server?

Re: I need some help with PHP (i'm kind of newbie)

Posted: Mon Mar 24, 2008 10:37 am
by skinnycat
yes, I am

Re: I need some help with PHP (i'm kind of newbie)

Posted: Mon Mar 24, 2008 4:11 pm
by fiate2000
Do PHP versions differ between the server and local machine? What is the version on local machine?

Re: I need some help with PHP (i'm kind of newbie)

Posted: Mon Mar 24, 2008 5:53 pm
by skinnycat
nevermind...

I've found the problem, it looks like the php file needed to be in the www folder.
I also learned that the correct way to load a php file from internet explorer is http://localhost/filename.php.

just in case anyone has the same problem.