jaylearning Posted October 23, 2007 Share Posted October 23, 2007 hi thanks in advance for looking. a [quote] <playlist version="1" xmlns="http://xspf.org/ns/0/"> <trackList> <?php // Get the search variable from URL $var = @$_GET['/'] ; $trimmed = trim($var); //trim whitespace from the stored variable // rows to return $limit=1; // check for an empty string and display a message. if ($trimmed == "") { echo "<p>error</p>"; exit; } // check for a search parameter if (!isset($var)) { echo "<p>We dont seem to have a search parameter!</p>"; exit; } //connect to your database ** EDIT REQUIRED HERE ** mysql_connect("localhost","cast",""); //(host, username, password) //specify database ** EDIT REQUIRED HERE ** mysql_select_db("trailercast") or die("Unable to select database"); //select which database we're using // Build SQL Query $query = "select * from phpizabi_video where processed=1 AND id like \"%$trimmed%\""; // EDIT HERE and specify your table and field names for the SQL query $numresults=mysql_query($query); $numrows=mysql_num_rows($numresults); // If we have no results, offer a google search as an alternative if ($numrows == 0) { echo sorry; } // next determine if s has been passed to script, if not use 0 if (empty($s)) { $s=0; } // get results $query .= " limit $s,$limit"; $result = mysql_query($query) or die("Couldn't execute query"); // begin to show results set // now you can display the results returned while ($row= mysql_fetch_array($result)) { $title = trim($row['url']); } // make a simple variabel $strflv = $title; /* separating each word in previous variabel with explode() function, with double "greater than" sign as a delimiters */ $flvArray = explode(" ", $strflv); foreach($flvArray as $flv) { print "<track><location>".$flv."</location></track>"; } ?> </trackList> </playlist> output looks like this <playlist version="1" xmlns="http://xspf.org/ns/0/"> <trackList> <track><location>add.flv </location></track> <track><location>movietariler.flv </location></track> <track><location>add2.flv</location></track> </trackList> </playlist> need it to look like this - other wise the flash player dont work.. <playlist version="1" xmlns="http://xspf.org/ns/0/"> <track><location>add.flv</location></track> <track><location>movietariler.flv</location></track> <track><location>add2.flv</location></track> </trackList> </playlist> please can you tell me where im going wrong sorry im still learning.... (edited by kenrbnsn to change the to ) Quote Link to comment https://forums.phpfreaks.com/topic/74499-php-explode-help/ Share on other sites More sharing options...
marcus Posted October 23, 2007 Share Posted October 23, 2007 Try: explode("\n", $string); # $string being the variable exploded Quote Link to comment https://forums.phpfreaks.com/topic/74499-php-explode-help/#findComment-376495 Share on other sites More sharing options...
jaylearning Posted October 23, 2007 Author Share Posted October 23, 2007 thanks!!!! but it don't help.. Try: explode("\n", $string); # $string being the variable exploded Quote Link to comment https://forums.phpfreaks.com/topic/74499-php-explode-help/#findComment-376502 Share on other sites More sharing options...
manixrock Posted October 23, 2007 Share Posted October 23, 2007 I don't think anyone will actually read the pretty long code you just posted.. You should say exactly what your misunderstanding is. Quote Link to comment https://forums.phpfreaks.com/topic/74499-php-explode-help/#findComment-376512 Share on other sites More sharing options...
sneamia Posted October 23, 2007 Share Posted October 23, 2007 Try changing: print "<track><location>".$flv."</location></track>"; to echo '<track><location>' . str_replace("\n", '', $flv) . '</location></track>'; Also, in your second xml output, there is no open trackList. Is this intentional? Quote Link to comment https://forums.phpfreaks.com/topic/74499-php-explode-help/#findComment-376532 Share on other sites More sharing options...
BlueSkyIS Posted October 23, 2007 Share Posted October 23, 2007 maybe try this: print "<track><location>".trim($flv)."</location></track>"; trim will remove any white spaces or line breaks at the beginning and end of the string. it will remove line breaks in the form of "\n" as well as "\r\n". Quote Link to comment https://forums.phpfreaks.com/topic/74499-php-explode-help/#findComment-376534 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.