Borderline Posted August 23, 2009 Report Share Posted August 23, 2009 (edited) 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. Edited August 23, 2009 by Borderline Link to comment Share on other sites More sharing options...
jeffman Posted August 23, 2009 Report 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 Report 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
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now