Jump to content

[SOLVED] mysql query first result blank...


secoxxx

Recommended Posts

Im generating xml with php, eveything works fine except the first result is blank..

 

Any ideas?

 

<?php

header("Content-type: text/xml");

$connection = mysql_connect("localhost","xxxxx", "xxxxx")
or die ("could not connect to database");

$db = mysql_select_db("xxxxx",$connection)
or die ("Couldn't select database.");

$rs = mysql_query("SELECT * FROM video WHERE type = 'public' " .$active. "AND viewtime <> '0000-00-00 00:00:00' ORDER BY viewtime DESC LIMIT 0,10",$connection)
or die ("invalid query");

echo ("<ut_response status=\"ok\">");

echo ("<video_list>");
do { 
echo ("<video>");
echo ("<title>". $row['title']. "</title>");
echo ("<url>http://www.tsxxx.com/video/". $row['VID']. "</url>");
echo ("<thumbnail_url>http://www.tsxxx.com/thumb/". $row['thumb']."_". $row['VID'].".jpg</thumbnail_url>");
echo ("</video>");
} while ($row = mysql_fetch_assoc($rs));
echo ("</video_list>");

echo ("</ut_response>");
?>

Link to comment
Share on other sites

The do while loop will print the result, then loop through the returned query data, that's why you get a blank first result. You should use a while() loop instead.

 

<?php
while($values = mysql_fetch_array($results)){
     //print those values
}
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.