Topic: Converting PHP to Coldfusion

Caliber    -- 11-14-2006 @ 10:51 AM
  Hello All! OK maybe I went about my first post the wrong way. In my first post I included all of the code from the PHP page...I'm sorry for that. I have managed to convert most of the PHP code already, but there sections that are still giving me a problem. So I will post the parts I need help with. Thanx in Advanced!

      $query = mysql_query("SELECT buddylist FROM users WHERE username='$from' AND password='".$pwd."'");
      if(@mysql_num_rows($query) > 0) {
         $user_bl = mysql_fetch_assoc($query);
         $set_status = @mysql_query("UPDATE users SET is_online='".mysql_real_escape_string($_POST['away']+1)."', last_ping='".time()."' WHERE username='".mysql_real_escape_string($from)."'");

         $query = @mysql_query("SELECT message,sender FROM messages WHERE recipient='".mysql_real_escape_string($from)."'");
         header("Content-type: text/xml");
         print '<?xml version="1.0" encoding="ISO-8859-1"?>'."\n";
         print "<main>\n<numMessages>";
         if(@mysql_num_rows($query) > 0) {
            print mysql_num_rows($query) . "</numMessages>\n";
            while ($row = @mysql_fetch_assoc($query)) {
               print "<message>\n";
               print '<from>'.$row['sender']."</from>\n";
               print '<data>'.rawurldecode($row['message'])."</data>\n";
               print "</message>\n";
         } else {
            print "0</numMessages>\n";

         $delete_new = @mysql_query("DELETE FROM messages WHERE recipient='$from'");

         print "<buddyList>\n";

         $query = @mysql_query("SELECT username,is_online FROM users WHERE username IN('".str_replace(",","','", $user_bl['buddylist'])."') ORDER BY username ASC");
         print "<numBuddies>".mysql_num_rows($query)."</numBuddies>\n";

         if(mysql_num_rows($query) > 0) {
            while ($row = mysql_fetch_array($query, MYSQL_ASSOC)) {
               print '<user status="'.($row['is_online']==2 ? 'away' : ($row['is_online']==1 ? 'online' : 'offline')).'">'.$row['username'].'</user>'."\n";
         print "</buddyList>\n";
         print "</main>\n";
      } else {
            $set_status = @mysql_query("UPDATE users SET is_online='0', last_ping='".time()."' WHERE username='".mysql_real_escape_string($from)."'");
            print 'not_logged_in';

   case 'login':

no question is silly or stupid....its only silly and stupid when you don't ask!!!

Caliber    -- 11-27-2006 @ 1:20 PM
  Listen I successful converted the PHP code over to CF:p...Thanx for the help?.? Yeah!

no question is silly or stupid....its only silly and stupid when you don't ask!!!

phamtum    -- 09-26-2007 @ 2:00 AM
  Hi Caliber,

I was wondering if you can give me a hand with my php to coldfusion convertion?


// setting the directory to search for mp3 files
$dir = "mp3/";

// reading the directory and inserting the mp3 files in the playlist array
$playlist = array();
$fdir = opendir($dir);
while($i = readdir($fdir)) {
   // if a .mp3 string is found, add the file to the array
   if (strpos(strtolower($i),".mp3") !== false)
          $playlist[] = $i;
// close the directory

sort($playlist);// make an alphabetical ordered list (if you don't want an ordered list, just comment this line)
shuffle($playlist);// make a randomized list (if you don't want a randomized list, just comment this line)

header("Content-type: text/xml");
// echoing the playlist to flash
echo "<player showDisplay=\"yes\" showPlaylist=\"yes\" autoStart=\"no\">\n";
for ($i=0; $i<sizeof($playlist); $i++) {
   // for the title it filters the directory and the .mp3 extension out
   $title = str_replace(".mp3","",$playlist[$i]);
   // clean filename (convert "_" into " ")
   $title = str_replace("_", " ", $title);
   echo "  <song path=\"$dir{$playlist[$i]}\" title=\"$title\" />";
echo "</player>";

thanks in advance!!!

EasyCFM.COM ColdFusion Forums :