What am i doing wrong here? (php/mysql)

  • meisam
  • Student
  • Student
  • User avatar
  • Posts: 96
  • Loc: Richmond, BC

Post 3+ Months Ago

I cant see anything wrong with this can you? i get a blank page.

Code: [ Select ]
<?php
ob_start("ob_gzhandler");
$username="easyjizz_mysql";
$password="*********";
$database="easyjizz_mysql";

mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
//$query="SELECT * FROM video ORDER BY adddate DESC";
//$result=mysql_query($query);

//$num=mysql_numrows($result);




//This checks to see if there is a page number. If not, it will set it to page 1
if (!(isset($pagenum)))
{
$pagenum = 1;
}

//Here we count the number of results
//Edit $data to be your query
$result = mysql_query("SELECT * FROM video ORDER BY adddate DESC") or die(mysql_error());
$rows = mysql_num_rows($result);
mysql_close();

//This is the number of results displayed per page
$page_rows = 4;

//This tells us the page number of our last page
$last = ceil($rows/$page_rows);

//this makes sure the page number isn't below one, or more than our maximum pages
if ($pagenum < 1)
{
$pagenum = 1;
}
elseif ($pagenum > $last)
{
$pagenum = $last;
}

//This sets the range to display in our query
$max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows;

$i=0;
while ($i < $num) {


$title=mysql_result($result,$i,"title");
$vidid=mysql_result($result,$i,"VID");
$duration=mysql_result($result,$i,"duration");
$thumb=mysql_result($result,$i,"thumb");
$fixedtitle = strtolower(str_replace(" ", "-", $title));
$seconds = $duration;
$minutes = floor($seconds/60);
$secondsleft = $seconds%60;
if($minutes<10)
  $minutes = "0" . $minutes;
if($secondsleft<10)
  $secondsleft = "0" . $secondsleft;


echo "
<fieldset id=\"address\">

<p align=left><b>$title</b><br>
<img src=\"hxtp://thumbs.easyjizz. com/$vidid/$thumb.jpg\"><br>
<a href=\"hxtp://www.easyjizz .com/video/$vidid/$fixedtitle\">hxtp://www.easyjizz .com/video/$vidid/$fixedtitle </a> <br>
$minutes:$secondsleft</p></fieldset></center><br>

</form></div><br>";

$i++;
}
?>
  1. <?php
  2. ob_start("ob_gzhandler");
  3. $username="easyjizz_mysql";
  4. $password="*********";
  5. $database="easyjizz_mysql";
  6. mysql_connect(localhost,$username,$password);
  7. @mysql_select_db($database) or die( "Unable to select database");
  8. //$query="SELECT * FROM video ORDER BY adddate DESC";
  9. //$result=mysql_query($query);
  10. //$num=mysql_numrows($result);
  11. //This checks to see if there is a page number. If not, it will set it to page 1
  12. if (!(isset($pagenum)))
  13. {
  14. $pagenum = 1;
  15. }
  16. //Here we count the number of results
  17. //Edit $data to be your query
  18. $result = mysql_query("SELECT * FROM video ORDER BY adddate DESC") or die(mysql_error());
  19. $rows = mysql_num_rows($result);
  20. mysql_close();
  21. //This is the number of results displayed per page
  22. $page_rows = 4;
  23. //This tells us the page number of our last page
  24. $last = ceil($rows/$page_rows);
  25. //this makes sure the page number isn't below one, or more than our maximum pages
  26. if ($pagenum < 1)
  27. {
  28. $pagenum = 1;
  29. }
  30. elseif ($pagenum > $last)
  31. {
  32. $pagenum = $last;
  33. }
  34. //This sets the range to display in our query
  35. $max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows;
  36. $i=0;
  37. while ($i < $num) {
  38. $title=mysql_result($result,$i,"title");
  39. $vidid=mysql_result($result,$i,"VID");
  40. $duration=mysql_result($result,$i,"duration");
  41. $thumb=mysql_result($result,$i,"thumb");
  42. $fixedtitle = strtolower(str_replace(" ", "-", $title));
  43. $seconds = $duration;
  44. $minutes = floor($seconds/60);
  45. $secondsleft = $seconds%60;
  46. if($minutes<10)
  47.   $minutes = "0" . $minutes;
  48. if($secondsleft<10)
  49.   $secondsleft = "0" . $secondsleft;
  50. echo "
  51. <fieldset id=\"address\">
  52. <p align=left><b>$title</b><br>
  53. <img src=\"hxtp://thumbs.easyjizz. com/$vidid/$thumb.jpg\"><br>
  54. <a href=\"hxtp://www.easyjizz .com/video/$vidid/$fixedtitle\">hxtp://www.easyjizz .com/video/$vidid/$fixedtitle </a> <br>
  55. $minutes:$secondsleft</p></fieldset></center><br>
  56. </form></div><br>";
  57. $i++;
  58. }
  59. ?>
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8416
  • Loc: USA

Post 3+ Months Ago

Possibly that mysql_close(); on line 27.

You are also not using the variable $max you set up on line 46.

Here is another possibility (probably the one which is the problem)... it looks like the way you are using mysql_result() is: (line 52-55)
Code: [ Select ]
mysql_result($result_resource, $offset, $row);

The way it is supposed to be
Code: [ Select ]
mysql_result($result_resource, $row, $offset);

so
Code: [ Select ]
$title = mysql_result($result,$i,"title");

should become
Code: [ Select ]
$title = mysql_result($result,"title",$i);
  • PolishHurricane
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 1585

Post 3+ Months Ago

Since you may not be sure if your MySQL query & logic are correct you may want to put this at the end of your script to make sure the echo statements are even running:

PHP Code: [ Select ]
<?php
echo 'test';
?>
  1. <?php
  2. echo 'test';
  3. ?>


If you still cannot see "test", in output, then add this to the end of your script...

PHP Code: [ Select ]
<?php
ob_end_flush();
?>
  1. <?php
  2. ob_end_flush();
  3. ?>

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 101 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.