Jump to content

anthrt

Members
  • Posts

    24
  • Joined

  • Last visited

    Never

Everything posted by anthrt

  1. I'm doing some work with the Discogs API trying to serialize the data of a release for use in another local application. A release on Discogs is something like a music album, so it contains the tracklisting, artists, remixers etc. Here is a sample track row returned from the API (xml) <track> <artists> <artist> <name>Ramirez</name> <join>And</join> </artist> <artist> <name>Tajada</name> </artist> </artists> <title>Listen To The Drums</title> <duration>8:10</duration> </track> Which more simply looks like this: Ramirez And Tajada - Listen To The Drums On this, I need to class the artist "Tajada" as a guest on this track, however, the "role" is defined in the previous artist's XML row: <name>Ramirez</name> <join>And</join> How can I sort through the rows to 'swap' these around? Ideally it would look like this: <track> <artists> <artist> <name>Ramirez</name> </artist> <artist> <name>Tajada</name> <join>And</join> </artist> </artists> <title>Listen To The Drums</title> <duration>8:10</duration> </track> Thanks for any help.
  2. Try putting $sub = 0; Outside of the loop
  3. echo strtoupper(substr(md5(rand().rand()), 0, 5));
  4. echo "<a href=\"index.php?p=articles&name=".data['name']."\">".data['name']"</a>"; You're missing $ before your data variables.
  5. You're commenting out all of the lines where $test is defined. That's why it's not working.
  6. graph = new Graph(300,200,"auto"); missing a $
  7. http://uk.php.net/manual/en/function.htmlspecialchars.php
  8. Looks fine to me, have you checked the source in Firefox/IE (or whatever your browser is) to make sure that the variables are being filled in correctly? Also, if you're putting a lot of HTML in with your PHP code, you might want to look at the heredoc syntax.
  9. <?php $check = substr($url, 0, 7); if($check != 'http://') { $errors[] = "Your URL looks invalid, does it start with http://"; } ?>
  10. http://www.skoogo.com/search.php?subsearchforum=
  11. You arent doing any validation on the seeSaved variable in regex_tester.php, you can use any character and it exposes your absolute path. http://nancywalshee03.freehostia.com/regextester/regex_tester.php?seeSaved=hello http://nancywalshee03.freehostia.com/regextester/regex_tester.php?seeSaved=../ Out of curiosity, how are you generating the sample script's variable names? i.e. 6fzm0zcc etc?
  12. http://www.mcatzone.com/testsetting.php You aren't doing any validation on the first 2 textboxes, you can type letters, punctuation in there etc. Error in query: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ee' at line 1 You can also register with punctuation as your username, i.e. '''''"""!#@#@
  13. There are messages that are displayed, it's the $msg variable in the function. They are showing so obviously the condition is being met.
  14. Heh, good call. I never thought twice about that. Alas, it still doesn't seem to be working. I thought that would have been it, but I guess not. foreach ($songs as $song) { $song['Name'] = mysql_real_escape_string($song['Name']); $song['Artist'] = mysql_real_escape_string($song['Artist']); $song['Album'] = mysql_real_escape_string($song['Album']); $song['Genre'] = mysql_real_escape_string($song['Genre']); $song['Kind'] = mysql_real_escape_string($song['Kind']); $song['Size'] = mysql_real_escape_string($song['Size']); $song['Total Time'] = mysql_real_escape_string($song['Total Time']); $song['Year'] = mysql_real_escape_string($song['Year']); $song['Bit Rate'] = mysql_real_escape_string($song['Bit Rate']); $song['Sample Rate'] = mysql_real_escape_string($song['Sample Rate']); $song['Equalizer'] = mysql_real_escape_string($song['Equalizer']); $song['Play Count'] = mysql_real_escape_string($song['Play Count']); $song['Location'] = mysql_real_escape_string($song['Location']); if(checkrow($song, $msg)) { $sql = "query"; $query = $db->sql_query($sql); echo $msg; } The function is still the same as above.
  15. Yeah, that looked pretty crappy. Here it is cleaned up function checkrow(&$song, &$msg) { $song['Artist'] = utf8_decode($song['Artist']); $song['Name'] = utf8_decode($song['Name']); if(strpos($song['Kind'], 'movie') || strpos($song['Kind'], 'video')) { $msg = "<span class='error'>" . $song['Artist'] . ' - ' . $song['Name'] . " (Not added - movie file)</span><br>\n"; return false; } elseif($song['Total Time'] <= 30000) { $msg = "<span class='error'>" . $song['Artist'] . ' - ' . $song['Name'] . " (Not added - too short (30s))</span><br>\n"; return false; } elseif(empty($song['Name'])) { $msg = "<span class='error'>" . $song['Artist'] . ' - ' . $song['Name'] . " (Not added - no song title!) </span><br>\n"; return false; } elseif(empty($song['Artist']) || !isset($song['Artist']) || strlen($song['Artist']) <= 1) { $msg = "<span class='error'>" . $song['Artist'] . ' - ' . $song['Name'] . " (Not added - no artist name!)</span><br>\n"; return false; } // Below doesn't work elseif(empty($song['Equalizer']) || !isset($song['Equalizer'])) { $song['Equalizer'] = 'Unknown'; $msg = $song['Artist'] . ' - ' . $song['Name'] . " (Equalizer missing, setting equalizer to 'unknown')<br>\n"; return true; } // Below doesn't work elseif(empty($song['Genre']) || !isset($song['Genre'])) { $song['Genre'] = 'Unknown'; $msg = $song['Artist'] . ' - ' . $song['Name'] . " (Genre missing, setting genre to 'unknown') <br>\n"; return true; } else { $msg = $song['Artist'] . ' - ' . $song['Name'] . " (Added)<br>\n"; return true; } } Anyway, back to the problem. No, if it returns false it won't even reach the equalizer and genre variables. What I mean is, if anything above $song['Equalizer'] returns false, it won't matter about changing the equalizer variable because it won't reach it anyway. If none of them return false, but $song['Equalizer'] is empty, it should replace/set the variable to "Unknown" instead of it being blank. This isn't happening, and neither is it for the one below it.
  16. if ( 1 == 1) { what's the point in having that in there?
  17. I have a script which parses user's iTunes library files, in XML format and logs it to a DB so it can be displayed in their forum profile. Before it gets entered in the DB, some cleaning up/verification is done to the elements, i.e. song title, genre etc. I've written a function to do this and put it in a seperate functions file with some other ones. One of the verifications is to check that the current item in the XML file is not a movie file, this appears to be the only one of the verification steps that actually works. Also, the function (should) display a message which says why the track wasn't accepted, e.g. not long enough, missing song title etc. This message isn't displayed on the page. It also tries to fill in some non-essential data if it's missing, so if there's no genre defined for the track it replaces it with 'unknown'. Anyway, here's the function function checkrow(&$song, &$msg) { //global $song; // global $msg; $song['Artist'] = utf8_decode($song['Artist']); $song['Name'] = utf8_decode($song['Name']); if(strpos($song['Kind'], 'movie') || strpos($song['Kind'], 'video')) { $msg = "<span class='error'>" . $song['Artist'] . ' - ' . $song['Name'] . " (Not added - movie file)</span><br>\n"; return false; } else { if($song['Total Time'] <= 30000) { $msg = "<span class='error'>" . $song['Artist'] . ' - ' . $song['Name'] . " (Not added - too short (30s))</span><br>\n"; return false; } else { if(empty($song['Name'])) { $msg = "<span class='error'>" . $song['Artist'] . ' - ' . $song['Name'] . " (Not added - no song title!)</span><br>\n"; return false; } else { if(empty($song['Artist']) || !isset($song['Artist']) || strlen($song['Artist']) <= 1) { $msg = "<span class='error'>" . $song['Artist'] . ' - ' . $song['Name'] . " (Not added - no artist name!)</span><br>\n"; return false; } else { if(empty($song['Equalizer']) || !isset($song['Equalizer'])) { $song['Equalizer'] = 'Unknown'; $msg = $song['Artist'] . ' - ' . $song['Name'] . " (Equalizer missing, setting equalizer to 'unknown')<br>\n"; return true; } else { if(empty($song['Genre']) || !isset($song['Genre'])) { $song['Genre'] = 'Unknown'; $msg = $song['Artist'] . ' - ' . $song['Name'] . " (Genre missing, setting genre to 'unknown') <br>\n"; return true; } else { $msg = $song['Artist'] . ' - ' . $song['Name'] . " (Added)<br>\n"; return true; } } } } } } } The problem is that the $song['Equalizer'] and $song['Genre'] variables aren't being rewritten with "unknown" if they're empty. All the other verification checks work, the messages and $song['Name'] gets shown etc. I'm not too sure about the references in the function parameters, I was just messing around trying to get it to work. Here's how the function is called foreach ($songs as $song) { $song_name = mysql_real_escape_string($song['Name']); $song_artist = mysql_real_escape_string($song['Artist']); $song_album = mysql_real_escape_string($song['Album']); $song_genre = mysql_real_escape_string($song['Genre']); $song_kind = mysql_real_escape_string($song['Kind']); $song_size = mysql_real_escape_string($song['Size']); $song_total_time = mysql_real_escape_string($song['Total Time']); $song_year = mysql_real_escape_string($song['Year']); $song_bit_rate = mysql_real_escape_string($song['Bit Rate']); $song_sample_rate = mysql_real_escape_string($song['Sample Rate']); $song_equalizer = mysql_real_escape_string($song['Equalizer']); $song_play_count = mysql_real_escape_string($song['Play Count']); $song_location = mysql_real_escape_string($song['Location']); if(checkrow($song, $msg)) { //$query = $db->sql_query("query"); echo $msg; } else { echo $msg; } }
  18. [quote author=ToonMariner link=topic=106499.msg425964#msg425964 date=1157121854] [code]<?php error_reporting(E_ALL); include('db.php'); $query = mysql_query("SELECT * FROM `vids` ORDER BY `setname`"); $cat = null; while($row=mysql_fetch_array($query)) { $title = $row['title']; $descr = $row['descr']; $img = $row['img']; $views = $row['views']; $setname = $row['setnamelong']; if (is_null($cat) || strcomp($cat,$setname) !=0) { $cat = $setname; echo <<<HTML <h1>$setname</h1><br /> <img src="$img" width="100" height="100" /><br /> <h1>$title</h1><br /> $descr </td>   </tr> </table><br /><br /> HTML; } else { echo <<<HTML <img src="$img" width="100" height="100" /><br /> <h1>$title</h1><br /> $descr </td>   </tr> </table><br /><br /> HTML; } } ?> [/code] BUT i fear you will get some very poorly formed html in there..... [/quote] works a charm, besides the html of course :) thanks to you both for posting.
  19. OK, so I have set up a script which will loop through a database (the database contains info on music videos, video thumbnail, number of downloads etc). It also contains the category the video is in, e.g. "english", "foreign" etc. The script is sorting and displaying the videos by category fine. What I would like it to do, is at the start of each category, display the title, so it would show "English" before the english category, then when it gets down to the "foreign" category, it would display the "Foreign" title. Currently the script is showing the category title before every video. For example: English [ english video here ] English [ english video here ] English [ english video here ] Foreign [ foreign video here ] Foreign [ foreign video here ] etc. I would only like it to show the category title one time. Another example: English [ english video here ] [ english video here ] Foreign [ foreign video here ] [ foreign video here ] You get the point. Here's what I have so far. Pretty simple but it does the job. In this case, `setname` would be the category i'm referring to, e.g english. [code]<?php error_reporting(E_ALL); include('db.php'); $query = mysql_query("SELECT * FROM `vids` ORDER BY `setname`"); while($row=mysql_fetch_array($query)) { $title = $row['title']; $descr = $row['descr']; $img = $row['img']; $views = $row['views']; $setname = $row['setnamelong']; echo <<<HTML <h1>$setname</h1><br /> <img src="$img" width="100" height="100" /><br /> <h1>$title</h1><br /> $descr </td>   </tr> </table><br /><br /> HTML; } ?>[/code] I've trimmed some of the HTML out just to make it easier to look through.
  20. im not sure if youre doing this already, but you have to actually execute the query.. ex $event = mysql_query($query);
×
×
  • 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.