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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
skinnycat
Forum Newbie
Posts: 4
Joined: Fri Mar 21, 2008 5:20 pm

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

Post 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.
Resco
Forum Newbie
Posts: 3
Joined: Mon Mar 24, 2008 6:41 am

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

Post by Resco »

You're sure you got PHP running on your local server?
skinnycat
Forum Newbie
Posts: 4
Joined: Fri Mar 21, 2008 5:20 pm

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

Post by skinnycat »

yes, I am
fiate2000
Forum Newbie
Posts: 1
Joined: Mon Mar 24, 2008 3:59 pm

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

Post by fiate2000 »

Do PHP versions differ between the server and local machine? What is the version on local machine?
skinnycat
Forum Newbie
Posts: 4
Joined: Fri Mar 21, 2008 5:20 pm

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

Post 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.
Post Reply