Borderline Posted August 23, 2009 Share Posted August 23, 2009 I have been adapting this code, that I originally wrote in April, however, I am receiving the error message mentioned above. Could anyone point out my error? <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><link rel="stylesheet" type="text/css" href="http://www.equinefocus.co.uk/style/20090405.css"/><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Equine Focus Photography</title></head> <body><?php // Connects to your Database mysql_connect("*****", "******", "*****") or die(mysql_error()); mysql_select_db("*****") or die ("Unable to connect to MySQL"); // mysql $per_page = 12; if (!isset($_GET['page']) || !is_numeric($_GET['page'])) { $page = 1; } else { $page = (int)$_GET['page']; } $from = (($page * $per_page) - $per_page); $sql = "SELECT * FROM photos WHERE date='2009-05-30' LIMIT $from, $per_page";?><?php while($info = mysql_fetch_array($data)) { // images $thumb='/photos/'.$info['date'].'/thumbs/'.$info['thumb']; $url='/photos/'.$info['date'].'/'.$info['url']; $ref = $info['date'].'-'.$info['ref'];?><?php $total_results = mysql_fetch_array(mysql_query("SELECT COUNT(*) AS num FROM photos")); $total_pages = ceil($total_results['num'] / $per_page); if ($page > 1) { $prev = ($page - 1); echo "<a href=\"?page=$prev\"><< Previous</a> "; } for($i = 1; $i <= $total_pages; $i++) { if ($page == $i) { echo "$i "; } else { echo "<a href=\"?page=$i\">$i</a> "; } } if ($page < $total_pages) { $next = ($page + 1); echo "<a href=\"?page=$next\">Next >></a>";}?> <div class='img'> <a href="<?php echo $url;?>"><img src="<?php echo $thumb; ?>"</a> <div id='refno'><?php echo $ref; ?></div> <div id='info'><?php echo $info['horse']; ?></div> <div id='info'><?php echo $info['rider']; ?></div> </div><?php} ?></body></html> The error message would appear to relate to this: <?php while($info = mysql_fetch_array($data)) { // images $thumb='/photos/'.$info['date'].'/thumbs/'.$info['thumb']; $url='/photos/'.$info['date'].'/'.$info['url']; $ref = $info['date'].'-'.$info['ref'];?> Any advice greatly appreciated. Link to comment Share on other sites More sharing options...
jeffman Posted August 23, 2009 Share Posted August 23, 2009 $data has no value. Did you mean to pass $sql to the db function? Link to comment Share on other sites More sharing options...
Borderline Posted August 23, 2009 Author Share Posted August 23, 2009 $data has no value. Did you mean to pass $sql to the db function?Ah, thank you, forgot to alter this part of the code. Works as it should now! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.