View Full Version : addslashes() issue

10-29-2007, 04:51 AM
I am trying to put add slashes to a script and it is not doing and it returns nothing so could someone please look and tell me what the issue is?

$location= addslashes($row['song_file']);
$image= addslashes($row['image_file']);

//XML Header
$XML = '<?xml version="1.0" encoding="UTF-8"?>';
$XML .= "
<playlist version='1' xmlns='http://xspf.org/ns/0/'>

//loop through all Tracks in database
while($row = mysql_fetch_assoc($result)){

$XML .= "<track>\n";
$XML .= "<title>" . $row['song_name'] . "</title>\n";
$XML .= "<location>http://store.labelfreeartists.com/" . $location. "</location>\n";
$XML .= "<image>http://store.labelfreeartists.com/" . $image. "</image>\n";
$XML .= "<info>" . "http://store.labelfreeartists.com/product_info.php?products_id=".$row['cart']. "</info>\n";
$XML .= "<lyrics>" . "view_lyrics.php?song_id=" . $row['id'] . "</lyrics>\n";
$XML .= "<add>" . "add_song.php?id=" . $row['id'] . "&member_id=".$row['original_id']. "</add>\n";
$XML .= "<rate>" . "rate_songs.php?id=" . $row['id'] . "</rate>\n";

$XML .= "</track>\n";


//XML Footer
$XML .= "</trackList>

I am trying to add slashes to the $location and $image and after the XML file is written it there is nothing where the variables should be. anyone got a clue?

10-29-2007, 07:01 AM
yeah...I'm an idiot and forgot to put the variable inside the while loop

10-29-2007, 01:21 PM
Ummm. We noticed that. That is probably why no one bothered to answer. The error in the logic is obvious to anyone who actually looked at the code.

People, not just Jacobb123, when you have code that does not function as you intend, as the first step in troubleshooting it, it is your job as the programmer who wrote the code or are re-using code you got from some place to read through it to make sure the logic is doing what you want it to do. Programs can only do what the program logic says to do and the program logic is what you as the programmer wrote or are re-using.

Just posting code in a Forum, stating it does not work or has an error, and asking some other programmer to tell you what is wrong with it, should not be your first troubleshooting step. It takes a really long time to produce code that accomplishes anything when you wait around for someone in a Forum to troubleshoot your code, when reading it, reading the error message, reading a programming language reference, or searching the Internet will usually solve the problem in a small fraction of the time.

Frankly, programming forum members would rather read and try to solve real programming problems, rather than proof read bogus program logic or language syntax errors.