Jump to content

[SOLVED] help with pagination tutorial - white page


aebstract

Recommended Posts

$conn = mysql_connect('_','_','_') or trigger_error("SQL", E_USER_ERROR);
$db = mysql_select_db('_',$conn) or trigger_error("SQL", E_USER_ERROR);

$sql = "SELECT  COUNT(*) FROM photo_gallery";
$result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR);
$r = mysql_fetch_row($result);
$numrows = $r[0];

$rowsperpage = 18;
$totalpages = ceil($numrows / $rowsperpage);

if (isset($_GET['currentpage']) && is_numeric($_GET['currentpage'])) {
   $currentpage = (int) $_GET['currentpage'];
} else {
   $currentpage = 1;
}

if ($currentpage > $totalpages) {
   $currentpage = $totalpages;
}
if ($currentpage < 1) {
   $currentpage = 1;
}

$offset = ($currentpage - 1) * $rowsperpage;

$sql = "SELECT id, photoname FROM photo_gallery LIMIT $offset, $rowsperpage";
$result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR);

while ($list = mysql_fetch_assoc($result)) {
$photoname = $list['photoname'];
$echo_gallery = "<div class=\"photo\">$photoname</div>";
}

 

I've been trying to figure out the problem and I can't even seem to isolate it. I really hope it is something stupid and overlooked. This code is almost exact to the pagination tutorial code and it's producing a white page issue. If I take the code out, the page displays normal.

Neat:

 

Warning: mysql_connect() [function.mysql-connect]: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in /hermes/web03/b500/pow.berryms/htdocs/new/photos.php on line 4

Fatal error: SQL in /hermes/web03/b500/pow.berryms/htdocs/new/photos.php on line 4

 

I'm guessing it's some sort of issue with the username/password/database I'm using? I'm sure it's right since I set it up just before I put the info in. Could it have anything to do with using localhost? I've always used it in the past but I think I've heard that some servers you can't use it and this is definitely a new server for me to be on.

Warning: mysql_connect() [function.mysql-connect]: Can't connect to MySQL server on '127.0.0.1' (111) in /hermes/web03/b500/pow.berryms/htdocs/new/photos.php on line 4

Fatal error: SQL in /hermes/web03/b500/pow.berryms/htdocs/new/photos.php on line 4

 

;(

Archived

This topic is now archived and is closed to further replies.

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